Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
photo of Jennifer Kyrnin

Jennifer's Web Design / HTML Blog

By Jennifer Kyrnin, About.com Guide to Web Design / HTML since 1997

Poll: Do you understand CSS specificity?

Thursday August 14, 2008

CSS specificity is one of the aspects of CSS that can be very confusing at first, and hard to remember even after you understand it. The idea is that if you have two rules that target the same general element, you need a way to determine which one the browser implements. At its most basic, if you set the font color on paragraph tags twice in one CSS document, the last one to be read will be applied. But what if you have a paragraph that has both an id and a class set, and there are styles for each of those? Specificity says that the ID style will take precedence over a class - because it's more specific (there can only be one element with an ID on a page, but there can be many elements with the same class).

Comments

August 14, 2008 at 10:29 am
(1) Wardell says:

This is an aspect of css that comes in very handy for me. I think every web designer should have a firm understanding of it, and the different ways to implement it, it’s not too complex.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Web Design / HTML

About.com Special Features

Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2009 About.com, a part of The New York Times Company.

All rights reserved.