css question - re styling the bold tag

Discussion in 'HTML & Website Design' started by jgjg, Oct 29, 2007.

  1. #1
    ok...lets say one of the cells in my html table has the class: cell4

    and the css definition is:

    .cell4 {
    background: #FFFFFF;
    padding: 5px;
    font: 11px Arial, Helvetica, sans-serif;
    }

    Lets say I want all of the <b> tags in this cell to be navy blue, 12 pt...

    How can I set the b tag to only affect this cell?

    If I use:

    b {
    font: bold 12px Arial, Helvetica, sans-serif;
    color: #000066;
    }


    It works, but all of the bold tags in the other cells on the page turn blue too :(

    any ideas?
     
    jgjg, Oct 29, 2007 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Target by the class

    .cell4 b {
    font: bold 12px Arial, Helvetica, sans-serif;
    color: #000066;
    }

    one of the most important features of CSS is the abiltity to group a bunch of tags under one class or ID, then target them by the wrapper instead of slapping classes on each and every tag.

    You see it in menus all the time where people will go:
    <ul>
    	<li class="lineItem">Item 1</li>
    	<li class="lineItem">Item 2</li>
    	<li class="lineItem">Item 3</li>
    	<li class="lineItem">Item 4</li>
    </ul>
    Code (markup):
    to target each li with ".lineItem", when it would be faster to go:

    <ul class="lineItems">
    	<li>Item 1</li>
    	<li>Item 2</li>
    	<li>Item 3</li>
    	<li>Item 4</li>
    </ul>
    Code (markup):
    to target those as ".lineItems li"
     
    deathshadow, Oct 29, 2007 IP
  3. jgjg

    jgjg Peon

    Messages:
    595
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks got it now
     
    jgjg, Oct 29, 2007 IP