Jump to content

Recommended Posts

they have this css precedence formula that goes like this:

 

inline style = 1000

id tag = 100

class tag = 10

redefine an html tag like a td = 1

 

now say I have a css definition like this:

#ID1 #ID2 a { color:red; }

the precedence value of that would be 201, 2 IDs plus one html redefinition

 

if I then had this code that uses the css definition above:

<div id="ID1"><div id="ID2"><a href="" style="color:green;">test</a></div></div>

--that link will be green not red! that's because the style tag has a precedence value of 1000 and beats the 201 above.  You can use the formula above like I used to figure out the precedence of what style beats what when conflicts occur.  Whoever has the highest total will win!

 

Since the inline style tag is closer to the code, the standards people determined that it should always wins.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.