SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Coding to XHTML Strict 1.0 - Alternative to <u> tag?

    Hi there,

    I have found out from many documents on the net, that the <u> tag isn't supported in the XHTML strict doctype - whats the alternative that can be used for underlining?


    Kind Regards

    James

  2. #2
    SitePoint Enthusiast splashpoint's Avatar
    Join Date
    Jun 2004
    Location
    UK
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apply the following rule to a CSS class or id

    [css]text-decoration:underline; [/css]

    From a usability POV it's best not to underline anything that isn't a link

  3. #3
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is that the only way of doing it?

    Thanks

    james

  4. #4
    SitePoint Enthusiast splashpoint's Avatar
    Join Date
    Jun 2004
    Location
    UK
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe so yes. I suppose you could add a bottom-border if you want, but i don't believe there's a specific tag for it. With XHTML & CSS you should be trying to separate presentation from content anyway (so CSS is the way forward)

    hth

  5. #5
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends on why you want to underline a piece of text.

    Is it a heading? Use <h1>-<h6>.

    Is it an emphasized word? Use <em>.

    Is it text that has been inserted after a document edit? Use <ins>.

    Is it an instance of a term that is being defined? Use <dfn>.

    And so forth. If HTML doesn't have an element type for the purpose then use a <span>.

    Then you can alter the presentation of that element with CSS as described above.
    Simon Pieters

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The whole idea with Strict doctypes is the separation between content, presentation and behaviour. Underlining is presentation, so it should be handled via CSS.

    As Simon said, choose the appropriate element type, add some way to reference it using an ID or class as splashpoint said, and assign a CSS rule to achieve the underlining.

    BTW, this applies to HTML 4.01 Strict as well as XHTML 1.0 Strict and XHTML 1.1. It's not an XHTML vs HTML issue, it's a Strict vs Transitional thing.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys for your help

  8. #8
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    style="text-decoration:underline;" is the best option.

  9. #9
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    no it isn't, inline styles are bad!


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
  •