CSS CSS CSS Author Graphic: Adam Ducker

Site Navigation

Main Content

CSS Specificity

July 14, 2008 @ 11:26 am

A member of CSS-Discuss today was having a problem with a centered P tag not actually being centered in the browser. When I saw what the problem was I had a flashback of my early days with CSS and I understood how this person felt. The problem was with CSS Specificity, a concept I didn’t know about for a long time and my work suffered for it.

I understood the concept of the cascade and the relationship of external versus internal versus in-line styles, but I didn’t understand that there were forces acting on the CSS beyond all that. To me CSS was a kind of a roll of the dice in that sense. My CSS ended up very dense and I abused the !important rule. Shame on me.

I was reading a CSS book in Barnes and Noble a few years back and I came across the concept of specificity, and my life hasn’t been the same since. At least as far as CSS goes. So I think that specificity is an incredibly important yet infrequently spoken of concept.

Another CSS-Discuss subscriber posted information about the other users problem while I was caught up looking for a decent article about CSS specificity, so here you go: Read more about CSS specificity on onderhond.com

Leave a Reply

Footer Links