Underlining text using CSS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manil
    New Member
    • Mar 2007
    • 8

    Underlining text using CSS

    Hi, I am new to the forum.

    I wanted to know if there's any way in which I can underline a phrase in a webpage using CSS. I tried using "text-decoration:unde rline;" but it looks like that works only with hyperlinks. Any suggestions/advice is greatly appreciated.

    Thanks...
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    Originally posted by Manil
    Hi, I am new to the forum.

    I wanted to know if there's any way in which I can underline a phrase in a webpage using CSS. I tried using "text-decoration:unde rline;" but it looks like that works only with hyperlinks. Any suggestions/advice is greatly appreciated.

    Thanks...
    That is the correct syntax.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <html>
            <head>
                <title>Coming...</title>
                    <style type="text/css">
                    .clsUnderline
                    {
                 	text-decoration: underline
    		}   
                    </style>
            </head>
                <body>
                   <div class="clsUnderline">
                        TEXT TEXT TEXT TEXT TEXT TEXT 
                   </div>
                </body>
    </html>

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      It should work for just about any text:

      <h1 style="text-decoration: underline">hell o world</h1>
      <div style="text-decoration: underline">the text in the div</div>
      etc
      etc
      etc

      Comment

      • Manil
        New Member
        • Mar 2007
        • 8

        #4
        thanks all for replying. I used your advise and it worked!

        Comment

        Working...