#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    62
    Rep Power
    12

    simple css question


    scenario: i applied some styles to the p (paragraph) tag, so text in a paragraph is a certain color and size and whatever. however when i attempt to put a word within the bold tag (<b>), nothing happens, the text i want to be bold is unaffected (its not bold like i want it to be). do you have to use a work around when it comes to making text bold in css? thanksNadvance
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    Well, since you're using CSS, you should't be using the <b> tag anyway b/c it's a formatting/style tag. Instead, use a <span> tag and apply a class to it and add that class to your stylesheet. That way, in the future, if you no longer want the words bold, but maybe italic instead, you can change just the stylesheet. After all, that is the advantage.
    Code:
    <style type="text/css">
    p
      {
      color: red;
      font-size: 1em;
      }
    .keyword
      {
      font-weight: bold;
      }
    </style>
    Code:
    <p>This is some a <span class="keyword">keyword</span>, which is bold!</p>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    62
    Rep Power
    12
    thanks jharnois,
    actually i never heard of the span tag, is it a generic tag meant to be applied to miscelaneous styles?
  6. #4
  7. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    It's an inline tag whereas <p> is a block tag.
  8. #5
  9. This is only a test
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Off the air
    Posts
    2,893
    Rep Power
    153
    <span> is a tag that's meant only for carrying style information; it has no effect on its own. When you stick a style into a <div> tag, for example, you get the style information and the extra line break from <div>'s normal function. <span> doesn't have a normal function like that, so you can use it without it changing anything else.

IMN logo majestic logo threadwatch logo seochat tools logo