So I have an issue on how I should implement a few webpages. Since having more < link > would slow things down because more HTTP request = slower, I decided to put the desktop's, tablet's, and mobile's stylesheet into one single css file using @media rule. However, I have more than one page where every page has the same header and footer but different content section so I need to customize each content's css. My issue and question is whether to put all the content's css into the same single file so there is one css file or split it so there's a common css file plus another css for each page. Example structure of the differences:
Option 1 - One single css file:
- home.html
- common.css
- page-one.html
- common.css
- gallery.html
- common.css
=== or ===
Option 2 - Split css file:
- home.html
- common.css
- home.css
- page-one.html
- common.css
- p1.css
- gallery.html
- common.css
- gallery.css
Reason I can't decide which method is I'm not sure how css files are parsed. I assume web browsers go through the whole css file and looks for the tag (i.e: #myHeader) in the html from bottom to top then applies when it tags matches. Kind of like this:
while(!End Of *css* File){
while(!EO *html* F){
if(cssTag == htmlTag)
applyCss()
}
}
So, if in this case, I'd assume css tags that aren't even in the current html page would slow things down since it has to go through the whole html page to apply style or not before going to next style. Option 2 removes this issue but poses the issue of having an extra HTTP request each page. Now, my example has only 3 pages but I actually have 8-10 pages. With that many pages, the time spent looking to apply styles on the current page would be greater (Option1) but is it greater than an HTTP request (Option2)?
common.css+<style>block on pages (where necessary) ?