Forum Moderators: not2easy
header > #container > #widget > #notation header > #container > #widget > #notation {
.class1 { color: white }
.class2 { color: blue }
...
.class20 { color: black }
} header > #container > #widget > #notation .class1 { color: white }
header > #container > #widget > #notation .class2 { color: blue }
...
header > #container > #widget > #notation .class20 { color: black }
Let's say that I have a bunch of classes that are descendants of:
header > #container > #widget > #notation
But ... but ... but ... why? The #notation by itself is already unique.
header > #container > #widget > #notation .class1 { color: white } <header>
<div id="container">
<div id="widget">
<div id="notation">
<div class="class1">Howdy!</div>
<p>
<span class="class1">How are you?<span>
</p>
</div>
</div>
</div>
</header> You could use a pre processor liked Sass or Less. Then you could write exactly the example you gave and it would get processed to the CSS in your second example.
I think it would actually make the CSS run slower, because in addition to looking for class1, it then has to backtrack and see whether the element in question is located inside this complex hierarchy.
#notation .class1 { color: white }
#notation .class2 { color: blue }
...
#notation .class20 { color: black } the 2011 article says that targeting types is actually the slowest!Huh. Yeah, this is where we need someone with up-to-the-minute information, because seven years is quite a while in html/css years. The linked article gives examples from FF 6. Brr. But I'm fully prepared to believe that a * at the end is still inefficient.
This is why I find performance so interesting; it’s a weird balance between web standards best practices and sheer speed.Ain't that the truth.
It looks like there are some major performance issues using it on a production site, so it recommends just using it for development and then using the compiled code on the live site. So I'm thinking that the end user would still end up with the larger CSS, it would just be marginally easier to code on my end. Which is cool, but I was hoping to make the CSS smaller, too.
then what's the point of even being able to set up identifiers like that?It saves trouble for you. Every item in a specified list has a particular format. Every paragraph in a specified div has a particular format--in fact, much of the time that is the sole reason for the div's existence. Every cell in a specified table has a particular format. (Remember what tables looked like in raw HTML, before CSS existed?) It's not about shaving nanoseconds in idealized benchmarks; it's about making files smaller, tidier and easier to read.