6

Let's say we have a page with the some simple HTML/CSS like below. Does the 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; }

That is just an example, but in the real world there might be hundreds, thousands lines of CSS code isn't being used, such as using Bootstrap for a very very small project.

2
  • 3
    Yes, all the rules are read and loaded into memory. Hence why people try to minify their rules and eliminate the redundancies. Commented Feb 19, 2015 at 20:44
  • This is not exactly a duplicate, but you migth be interested on this question about CSS cache Commented Feb 19, 2015 at 20:50

1 Answer 1

4

Yes all the rules are loaded in the memory, this is why when you add new element to your DOM (e.g. by using javascript) you see that the style automatically applies to them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.