Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    455
    Rep Power
    13

    underlining using css rather than <u>?


    I've done a bunch of searches on how to get rid of the deprecated tag <u> and they all say to use a style sheet. But I can't find and css command for underlining...how do people do in a style sheet?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    26
    Rep Power
    0
    PHP Code:
    <p style="text-decoration: underline;">This Text Is Underlined</p
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    455
    Rep Power
    13
    Thanks. Just found that too, and I can do that in a styles sheet rather than inline.

    But that hooks the style to a paragraph tag which skips space before and after. And it doesn't seem to help to throw in a 'line-height:0' either. What's the trick for underlining a single word or phrase within a bigger paragraph?
  6. #4
  7. Thanks Johnny Hart (BC) R.I.P.

    Join Date
    May 2003
    Location
    Dallas
    Posts
    5,268
    Rep Power
    1956
    Code:
    style
    .underline {
        text-decoration: underline;
        }
    
    html
    <p>Now is the <span class="underline">time</span> for…</p>
    
    <h3 class="underline">Generic subheader</h3>
    hth

    gary
    There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

    My html and css workshop, demos and tutorials.
    Ask a better question, get a better answer.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    26
    Rep Power
    0
    You don't have to do it in a <p> tag, I was just using it to demonstrate. To be quite honest, I personally would use <u>, but if you must, try this:
    Code:
    .underline { text-decoration: underline }
    PHP Code:
    <span class="underline">This Text Is Underlined</span
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    455
    Rep Power
    13
    Perfect. Thanks, guys.
  12. #7
  13. Contributing (?) User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    uk
    Posts
    462
    Rep Power
    11
    all that to replace one simple lil tag, makes you wonder dont it
    hope that helps... take care... ian
    feel free to email me... the cockney one...
    ian*at*thereddevil.net
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    bournemouth
    Posts
    165
    Rep Power
    11
    Yeah it does seem stupid. I would use "u" for that. It jus means more code, and therefore a larger webpage.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Norwich, UK
    Posts
    53
    Rep Power
    13
    Originally Posted by asinsh
    I've done a bunch of searches on how to get rid of the deprecated tag <u> and they all say to use a style sheet.
    For the record <u> is not deprecated in HTML or XHTML as far as I'm aware. All that's really happened with the latest HTML specs is that more phrase elements have been added to push towards a separation of design and content, meaning that presentational elements such as <u> are no longer the most suitable tag for the vast majority of uses. However, if you're only using a tag around a peice of text so that it should be displayed as underlined then there's no reason not to use <u>. And if that's not the case then using a class called "underline" doesn't make any sense.
  18. #10
  19. No Profile Picture
    The Forest
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    321
    Rep Power
    13
    Just wondering, why do you necessarily need to underline an item? Generally, when viewing text on computers and such, items are italicized, not underlined. As far as I know, there is no semantic tag for underlining because it's preferred (as per the MLA) to use italics for electronic documents (which has a semantic tag).

    I'd agree it makes no sense to use a class for underlining: it removes all idea of separating presentation from content and structure when you have a bunch of <span>s in place of <font>s - just another meaningless tag.

    The <u> element was indeed deprecated, though. It has been since HTML 4.01, I believe.

    Hope that helps!

    Happy coding!
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    455
    Rep Power
    13

    Smile


    Originally Posted by nolachrymose
    Just wondering, why do you necessarily need to underline an item?...
    Ask my wife, who insists on having certain things underlined

    Originally Posted by nolachrymose
    ...I'd agree it makes no sense to use a class for underlining: it removes all idea of separating presentation from content and structure when you have a bunch of <span>s in place of <font>s - just another meaningless tag.

    The <u> element was indeed deprecated, though. It has been since HTML 4.01, I believe....
    Yup, it is silly indeed. Instead of a simple and I now have <span class="underline"> in every page where I need to underline and I also have a defnition of that class in my css sheet. All in the name of progress
  22. #12
  23. Contributing (?) User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    uk
    Posts
    462
    Rep Power
    11
    Originally Posted by asinsh
    Ask my wife, who insists on having certain things underlined All in the name of progress
    hey asinsh i had to laff at that remark soz mate

    i made my comment 'makes you wonder dont it' coz this css stuff has its place for sure, but sometimes they just screw things up even more, i mean whoeva in their right mind thort that replacing the indeed deprecated tag <u> with all that extra coding was for the good... not in my book
    in any event css isnt cross browser, i mean if i state in my style sheet i want the body to inherit a certain font or color (font-size: "12px"; font-family: "arial"; color: "#ffffff"}) why the heck do i then have to add this <body text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#137d7c">to the body tag to get nutscrape and mozilla to do as i ask ????? nuts
    hope that helps... take care... ian
    feel free to email me... the cockney one...
    ian*at*thereddevil.net
  24. #13
  25. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    Originally Posted by ian ocky
    in any event css isnt cross browser, i mean if i state in my style sheet i want the body to inherit a certain font or color (font-size: "12px"; font-family: "arial"; color: "#ffffff"}) why the heck do i then have to add this <body text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#137d7c">to the body tag to get nutscrape and mozilla to do as i ask ????? nuts
    this is just plain wrong, you don't have to use those attributes to make things work in mozilla and ns6.x+
    the error must lie elsewhere in your code,
    mozilla and ns6+ is more picky about correct syntax than msie.

    the only reason for crossbrowser problems is msie's lack of css1 and css2 support, ( not considering generation 4 of the browsers)
    Last edited by Akh; May 23rd, 2004 at 07:11 PM.
  26. #14
  27. Contributing (?) User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    uk
    Posts
    462
    Rep Power
    11
    hi akh

    the only reason for crossbrowser problems is msie's lack of css1 and css2 support
    thats excepted, but my comment is not just plain wrong, its just plain right, the example i gave is exactly how the browsers(s) behaive
    hope that helps... take care... ian
    feel free to email me... the cockney one...
    ian*at*thereddevil.net
  28. #15
  29. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    no, it is wrong when you say you have to add those attributes to get thing to work in moz/ns.
    then can handle the css just perfect,
    if they don't then you must have something wrong in your css-code.
    you can't blame browsers for faulty code.
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo