Joel
Joel

Reputation: 6107

Performance in CSS hierarchy

If I have the following HTML:

<div id="container">
   <div id="inner">
   </div>
</div>

Is there any difference , performance wise, between:

#container #inner {
      width:300px;
}

to

#inner {
      width:300px;
}

?

Upvotes: 0

Views: 180

Answers (3)

dheerosaur
dheerosaur

Reputation: 15172

As ids aren't supposed to repeat, you can simply select using #inner

Upvotes: 1

zack
zack

Reputation: 3198

wont really affect it,

just CSS selectors with a wide-matching key selector can hurt performance ..

some insight here: http://www.stevesouders.com/blog/2009/06/18/simplifying-css-selectors/

Upvotes: 1

ScottE
ScottE

Reputation: 21630

The performance difference will be inconsequential. Try optimizing other parts of your code!

That being said, it's generally best to be as non-specific as possible.

Upvotes: 3

Related Questions