Sunday, April 12, 2009

Priority order of Style for HTML tags

There are many different ways for specifying attributes (e.g bgcolor) for the HTML tags (e.g TD).

1. We can specify it as attribute of the tag itself (e.g <td bgcolr="white">)
2. We can specify it using the inline style (e.g <td style="background-color:white">)
3. Style can be declared within the page itself
(e.g <style> .mycolor {
<---------some other code------->

<td class="mycolor" >

4. The above style declaration can be done in external CSS file and it can be used in the td tag.

So now question is if we specify the attribute using use many of the above ways which one will be considered.
Normally inline Style declaration will take high priority, next priority it for the style declared in the page, then external CSS. Least priority is for the attribute of the HTML tag.

More Articles...

No comments:

Search This Blog