faqts : Computers : Internet : Web : CSS

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 6 people (100%) answered Yes
Recently 2 of 2 people (100%) answered Yes

Entry

If multiple styles have been defined for the same element, which does the browser use?

Jun 13th, 2000 05:48
Rey Nuņez, http://www.w3.org/TR/REC-CSS2/cascade.html#cascade


In cases where different styles have been specified for the same 
selector (cascading styles), the browser decides which of the styles 
should apply, based on the following order of precedence: 

- styles declared in a linked stylesheet are applied if there are none 
other specified. 
- if styles are specified for the same element or selector in an 
embedded stylesheet, these styles take precedence. 
- if an inline style attribute is specified for a particular element, 
that style takes precedence over all other declared styles.
 
It is important to remember this order of precedence, as this 
determines which style declarations are given preference over others. 
The only exception is with the use of the CSS !important pseudo-class 
property, which retains precedence over all declared styles.

Please see
http://www.w3.org/TR/REC-CSS2/cascade.html#cascade
for more information regarding style sheets cascade order.