I have a Page header - navigation bar, say page-header.html, that is included in all the pages in an application. The header has some css styles.
But sometimes the css styles of the application's internal pages affects the page header and vice versa.
I understand the rule of specificity and that you can add a custom id to your page header's css styles like for eg.
#navigation-bar12345 ul{
color:red;
}
where the id is unique and thus it helps to not override the styles of other pages and not getting overridden.
But say for eg., I have a link <a href>
in the page-header.html where I haven't applied any styles to it.
But inside an application page, say introduction.html, I have applied some page specific styles for the link attribute.
a {
color:red
}
Considering the above scenario, I have few questions :
1) In the above case where I have no style rules specified for the link attribute in the page-header.html, How do I avoid the link's styles to be overridden by introduction.html?
2) I have read about scoped css, It helps not to override the styles of other pages. But having all the styles inside the html page is an overhead and not a good practice?
3) Is there any way where you can protect your html page(page-header.html) from the rest of your application? In my case, I do not want any of my link elements(<a href>
) in page-header.html to be exposed to the styles of the other pages like introduction.html to prevent overriding.
4) Curious question - We have various widgets that are included in the pages. How do these widgets manage not manipulating other pages styles or protect their own styles from being overridden?
I have read articles and few stack overflow questions related to this but nothing has given me a clear idea yet. Thanks in advance for your help!