SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css question - re styling the bold tag

    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 web page turn blue too

    any ideas?

  2. #2
    SitePoint Wizard bronze trophy Centauri's Avatar
    Join Date
    May 2007
    Location
    Newcastle, Australia
    Posts
    3,718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .cell4 b {
    font: bold 12px Arial, Helvetica, sans-serif;
    color: #000066;
    }

  3. #3
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    though I would consider using an alternative to the bold tags. Ideally, try to avoid using tags/classes that imply appearance. CSS lets you so easily redefine appearance and position that names which identify those properties now, become incredibly poorly named later on when you change them. A class, leftColumn, seems like a good name until your client changes their mind and wants it on the right. Use classes like subHeading, mainMenu, footnote, songTitle, etc. Say what it is and your CSS will never confuse the issue, no matter how you choose to present it. This also makes your code much more portable so you can reuse it more easily for other clients and other websites.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd also use a far more meaningful class name than "cell4" - what is that anyway, a prison that stylesheet is styling, or a Web page?


Bookmarks

Posting Permissions

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