By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,445 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,445 IT Pros & Developers. It's quick & easy.

Underlining text using CSS

P: 8
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:underline;" but it looks like that works only with hyperlinks. Any suggestions/advice is greatly appreciated.

Thanks...
Mar 30 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,892
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:underline;" but it looks like that works only with hyperlinks. Any suggestions/advice is greatly appreciated.

Thanks...
That is the correct syntax.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2.     <html>
  3.         <head>
  4.             <title>Coming...</title>
  5.                 <style type="text/css">
  6.                 .clsUnderline
  7.                 {
  8.                  text-decoration: underline
  9.         }   
  10.                 </style>
  11.         </head>
  12.             <body>
  13.                <div class="clsUnderline">
  14.                     TEXT TEXT TEXT TEXT TEXT TEXT 
  15.                </div>
  16.             </body>
  17. </html>
  18.  
Mar 30 '07 #2

KevinADC
Expert 2.5K+
P: 4,059
It should work for just about any text:

<h1 style="text-decoration: underline">hello world</h1>
<div style="text-decoration: underline">the text in the div</div>
etc
etc
etc
Mar 30 '07 #3

P: 8
thanks all for replying. I used your advise and it worked!
Jun 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.