Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Lightbulb A Question About Specificity

    What has more priority, a style assigned through specificity or through a class in the tag, such as <td class="sample">?

  • #2
    New Coder
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    47
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Code:
    <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:

    Code:
    <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:

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

    I hope that answers your question!
    Asher
    Last edited by Asher01; 07-16-2011 at 07:26 AM. Reason: Corrections

  • Users who have thanked Asher01 for this post:

    JAG (07-20-2011)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote Originally Posted by JAG View Post
    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/
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by Asher01 View Post
    Code:
    <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:

    Code:
    <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:

    Code:
    <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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •