tags:

views:

37

answers:

3

Hi,

I was wondering if anyone knew of a tool that will, when given a number of css files/css rules and a selector - classname, id, element etc. Return all styles that apply with their precedence ordered.

I not, is this doable via JavaScript - I can get the css rules applicable to an element at the time, but can I get those that have been overridden?

+2  A: 

In Firebug you can see all qualified styles for any element. It lets you trace the precedence order, but requires you to use Firefox.

(The presentation image on the Firebug page actually shows this behavior. Note the font-size for the h1 selector has been overridden by the more specific .siteTitle class selector.)

jensgram
+1  A: 

Unless you are looking for something you can automate, Firebug should actually be able to solve this one for you. Bring up the context menu (right click) on an element on a pace, pick "Inspect element" and the Firebug pane appears. In the right hand side, you got all CSS rules relevant for the element - those that are overridden are marked with strike-through text:

Jørn Schou-Rode
I would prefer to automate, but obviously Firebug shows that it is possible in some way...thanks, I'm running Firebug here but I hadn't realized it showed the removed styles. Do you know if order displayed is by precedence?
"Firebug shows you the rules that cascade together to style each element. Rules are sorted in the order of precedence, and properties that have been overridden are stricken out." from http://getfirebug.com/css.html
barraponto
A: 

Try any developer toolbar for Iexplorer or Firefox. Most of them will be able to show exactly what style will be applied to elements. I recon that for example Firebug (addin for Mozilla Firefox) can show what styles will be applied, and where they are overwritten by other styles. Good luck ;). edit: IE Developer Toolbar also has this functionality.

Younes