2

High level overview question about the parsing and painting of an HMTL DOM:

Does the browser search stylesheets for classes found when it parses the DOM or does it search the DOM for classes found in the stylesheets?

I appreciate this question could be browser specific, and might not be applicable to all use cases, but find it an interesting question when it comes to optimisation, for example is it less efficient to have redundant classes in the DOM or in stylesheets.

Many thanks for any help.

Dan
  • 45
  • 4
  • 1
    "Does the browser search stylesheets for classes found when it parses the DOM or does it search the DOM for classes found in the stylesheets?" The former. Applies to most if not all major browsers. See [Why do browsers match CSS selectors from right to left?](http://stackoverflow.com/questions/5797014/why-do-browsers-match-css-selectors-from-right-to-left) – BoltClock Apr 05 '17 at 13:00
  • @BoltClock Thanks! I knew it was right to left, but not the order it matched. will really help me, I hope this question helps others. – Dan Apr 05 '17 at 13:21

0 Answers0