How the browser finds and displays CSS rules

Say we have a page with some simple HTML / CSS as shown below. .b browser also read .b and .c in the stylesheet?

HTML

 <div class="a">1</div> <div>2</div> <div>3</div> 

CSS

 .a { color: aqua; } .b { color: blue; } .c { color: cyan; } 

This is just an example, but in the real world there can be hundreds, thousands of lines of CSS code that are not used, for example, using Bootstrap for a very small project.

+6
source share
1 answer

Yes, all the rules are loaded into memory, so when you add a new element to the DOM (for example, using javascript), you see that the style is automatically applied to them.

+4
source

Source: https://habr.com/ru/post/982756/


All Articles