...

View Full Version : A Question About Specificity



JAG
07-16-2011, 12:04 AM
What has more priority, a style assigned through specificity or through a class in the tag, such as <td class="sample">?

Asher01
07-16-2011, 08:24 AM
<td class="sample">

Since the class="sample" is an 'Inline' code, that takes precedence over an 'Internal Style Sheet' (in the head section) and a 'External Style Sheet'.

It also takes precedence over any other 'Inline' code that was before it. For example, consider the following:




<tr class="row">
<td class="data">
A
</td>
</tr>



Since the "data" class is inside the "row" class, anything specified differently with the "data" class will take precedence.

A basic rule of the thumb is, whatever you told it to do last, it usually will do.

I don't believe you can specify changes to a "class" by using the style="" line .. so if you want a few data boxes to come out different your best bet would be to make an alternate data class, like:



<tr class="row">
<td class="data">
A
</td>
<td class="alt">
B
</td>
</tr>



I hope that answers your question!
Asher

abduraooft
07-16-2011, 09:07 AM
What has more priority, a style assigned through specificity or through a class in the tag, such as <td class="sample">?

Read http://www.htmldog.com/guides/cssadvanced/specificity/

JAG
07-20-2011, 01:56 AM
<td class="sample">

Since the class="sample" is an 'Inline' code, that takes precedence over an 'Internal Style Sheet' (in the head section) and a 'External Style Sheet'.

It also takes precedence over any other 'Inline' code that was before it. For example, consider the following:




<tr class="row">
<td class="data">
A
</td>
</tr>



Since the "data" class is inside the "row" class, anything specified differently with the "data" class will take precedence.

A basic rule of the thumb is, whatever you told it to do last, it usually will do.

I don't believe you can specify changes to a "class" by using the style="" line .. so if you want a few data boxes to come out different your best bet would be to make an alternate data class, like:



<tr class="row">
<td class="data">
A
</td>
<td class="alt">
B
</td>
</tr>



I hope that answers your question!
Asher


Thank you Asher, that does help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum