Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Parsing Order 2

Status
Not open for further replies.

thedji

Programmer
Jan 20, 2002
12
AU
Hi,

Can anyone list the order that styles are parsed in a document? ie. External Stylesheet then Embedded Stylesheet then In-Lin Style Definition, etc.

I think I've seen it at Microsoft's site, but I can't for the life of me find it again!

Thanks!
 
Yes, this is important to know.

In general, the priority is this (from high to low):
1. inline styles
2. styles defined in <head>
3. external styles

If there are several <style> tags inside <head> their priority depends on the order of appearance in code. In this example:
<style>
p {color:green}
</style>
<style>
p {color:red}
</style>
the text colour in <p> will be red as it's definition in 2nd style overrides the 1st one.

The same way [tt]<p style=&quot;color:blue&quot;>[/tt] will override both of them.

Hope it will help.
good luck


 
Dont forget that you can overwrite this order by using this:
a{color: red !IMPORTANT;}

so for example:

<a href=&quot; style=&quot;color:blue&quot;> link </a>
will still become red then.

Greetz, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top