I\'ve got below id selectors in a CSS file. Headerphoto and logo-box are inner id-selectors of header id. Do I really need to add those two as inner id-selectors? I can add them
you don't have to add the #header selector, but i've heard the page rendering is faster the more precise the selector was declared. In my opinion it doesn't matter.
It doesn't matter as long as only one of #headerphoto
and #logo-box
exist on each page and you're sure the structure for these three elements will be the same.
It only really matters to add the #header
ID if, on some pages, #headerphoto
and #logo-box
appear in elements that don't have id="header"
, your stylesheet is used by all these pages, and you want the styles to apply if and only if these elements are in that one. But in such a case, that'd make your page structure rather inconsistent, wouldn't it?
Regarding performance, whether it's faster, slower or the same to nest ID selectors, I don't care, and neither should you, the stylesheet author, since ID selectors are already the fastest anyway.