How to Underline Text in HTML

Techwalla may earn compensation through affiliate links in this story.
HTML code on a screen.
Image Credit: Scott Cartwright/iStock/Getty Images

While you can underline text in HTML by enclosing the text in the tag -- for example, "this text is underlined" -- the preferred approach is to create a cascading style sheet, define a style element and apply the element to the text you want to underline. For example, place the following CSS between the tags:


Video of the Day

and place the following between the HTML


this text is underlined.


Common Conventions for Emphasizing Text

In HTML5, the tag should be used to label proper Chinese names and to indicate misspelled words. Since underlined text typically signifies a hyperlink on a Web page, you should use a different attribute, such as boldface or italics, to emphasize text. When you use a cascading style sheet to define the style for emphasized text, you need only change a single style element to automatically convert all underlined text to boldface or italics. For example, change the previous CSS style element definition to ".emphasis { font-weight:bold;}" or ".emphasis { font-style:italic; }" (no quotes).




Report an Issue

screenshot of the current page

Screenshot loading...