CSS Selector Classes on an ID

Want to add a combination of ID and class to a selector? Here’s a nice little piece of CSS. Let’s say you have code like this:

Hello world!

If you want to write a selector based on that element having both that ID and class name in combination (for an even tighter degree of specificity), you can write that selector like so:

div#foo.bar

That CSS selector will match your element. Again, the format is element#id.class.

technorati tags:, , , ,

Comments are closed.

I'm Reading…
Search This Site

AddThis Feed Button

Need great hosting?

Categories