#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    In a multi-cultural mess.
    Posts
    569
    Rep Power
    14

    Is there a "neutral" HTML tag to hold CSS class or id specification ?


    I have a paragraph --

    <p>Now is the time for all good men...</p>

    Several phrases are highlighted with color --

    <p>Now is the <font color="red">time</font> for
    all <font color="green">good</font> men ...</p>

    I want to use css instead of the font tag.
    I can use <i> or <b> tags with "css id or class" --

    <p>Now is the <i id="myRed">time</i> for
    all <b id="myGreen">good</b> men ...</p>

    My question -- Is there a tag that does nothing?
    Just allows you to invoke some css id or class?

    What "neutral" tag can I use in place of the following question marks?
    <??? id="myRed">

    I feel like I am missing the obvious way to do this ( without <font> ).

    Robert
    Robert
    ---
    If it's hard, it's probably wrong.
  2. #2
  3. A PAtCHy sErver
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Italy
    Posts
    408
    Rep Power
    13
    Try something like this:

    <span class="green">my text in green</span>
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Pittsburgh, PA, USA
    Posts
    13
    Rep Power
    0
    or:

    <div id="myRed">text</div>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    In a multi-cultural mess.
    Posts
    569
    Rep Power
    14
    dunxster and pippo,

    Thanks for the ideas. I tried the following on NN4.7

    Now is the <span id="bfgRed">time</span> for all <div id="bfgGreen">good</div> men to ...

    <span... was ignored.
    <div... made the word "good" green, but isolated "good" on a separate line.

    Maybe it would work on IE?

    Perhaps the HTML authors didn't see a need for an "exit" or a "no operation" for css.

    Robert
    Robert
    ---
    If it's hard, it's probably wrong.
  8. #5
  9. No Profile Picture
    CF sMod
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Maine, USA (a.k.a. Boonies)
    Posts
    242
    Rep Power
    14
    <span> is an inline element, you can have an unlimited amount of them on the same line.
    <div> is a block-level element, you can only have one on a line (unless you change its style to display:inline).

    Use <span>, NS4 has no problems with, perhaps it was something in your stylesheet which threw it, or perhaps it was the id attribute in the <span>? I know NS4 has no problems with <span class="bla">
    Jason Contact Me
    Super moderator @ CodingForums
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Belgium
    Posts
    10
    Rep Power
    0

    Exclamation when to use SPAN or DIV tags


    When using styles for fragment of text you use the SPAN-tag. If it's a complete block of text you want to manipulate, use the DIV-tag. This is very clear when you use the background-color property on those tags.
    When using the SPAN-tags around one word, together with background-color, only that word will have the specified bg-color. When using the DIV-tag on that same word, the whole line will have that background-color.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    In a multi-cultural mess.
    Posts
    569
    Rep Power
    14

    Thumbs up SPAN and DIV is right. css comments can't be //


    Thank you all -- jakke, jkd, dunxster, pippo

    You were right <span and <div do work as you said.

    It was my error.

    I had an invalid comment at the end of a css line as suggested
    by jkd ( thank you ). It negated the following css line.
    So bfgRed was not recognized.
    Yet bfgGreen was OK.

    #fInDataHor {background-color: 33cc66; color: black; } // invalid comment
    #bfgRed {color: ff0000;}
    #bfgGreen {color: 00ff00;}

    Robert
    Robert
    ---
    If it's hard, it's probably wrong.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    1
    Rep Power
    0
    Hi Robert,

    You can use <span>, for in-line formating (i.e. no caridge returns) or <div> for block formating. Neather of these tags have any formating other than layout, so all you'll need to do is set the color to red using css as other properties will be inherited from the <p> tag.

    Hope this helps.

    Pete.
  16. #9
  17. No Profile Picture
    Web Weaver
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Australia
    Posts
    64
    Rep Power
    15
    This may be a bit of a dumb question but how do you do a proper comment within CSS? I thought it was //...
    Never say never.
  18. #10
  19. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    15
    Rep Power
    0

    Lightbulb


    Comments in CSS are as follows:
    /* some comment goes here */
    /* this is another one */
  20. #11
  21. No Profile Picture
    Web Weaver
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Australia
    Posts
    64
    Rep Power
    15
    ah, I see now... thanks
    Never say never.
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Belgium
    Posts
    10
    Rep Power
    0
    /**************************************
    you can always span this comment
    over different lines ;-)
    which is handy to subdivide a long Style Sheet
    ***************************************/
    Last edited by jakke; July 30th, 2001 at 05:28 PM.

IMN logo majestic logo threadwatch logo seochat tools logo