W3docs

HTML <u> Tag

Use <u> Tag to specify an underlined text. Which specifies text that is stylistically different from normal text. Learn how to use <u> tag with examples.

In HTML 4.01, the <u> element was used to specify underlined text. However, using HTML purely for stylistic effects is no longer considered good practice. HTML should instead be used for adding structure and semantic meaning.

In HTML5, the <u> element was redefined with a specific semantic meaning. It represents a span of text that is stylistically different from normal text, such as misspelled words or proper nouns in Chinese.

The <u> tag defines a span of text having an unarticulated but exactly rendered annotation. This means that the web developer and browser can choose how to present the annotation. Browsers typically render text inside <u> tags as underlined by default, but this visual styling can be overridden with CSS.

Danger

Do not use the <u> element solely for visual underlining. In HTML5, it carries a specific semantic meaning. For purely stylistic underlining, use the CSS text-decoration property set to underline.

In some cases, consider using other elements, such as:

  • <em> for stress emphasis,
  • <b> for drawing attention to a text,
  • <cite> for book titles,
  • <i> for technical terms,
  • <mark> for highlighting phrases or key words,
  • <strong> for specifying a text with strong importance.

If you want to add textual annotations, use the <ruby> tag.

Syntax

The <u> element comes in pairs. The content is written between the opening (<u>) and closing (</u>) elements.

Example of the HTML <u> tag:

Example of the HTML <u> Tag|W3Docs

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
  </head>
  <body>
    <p>Here we used <u>the &lt;u&gt; element</u>.</p>
  </body>
</html>

Result

u tag example

Example of the CSS text-decoration property:

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document.</title>
    <style>
      span {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <p>Here we used <span> CSS property text-decoration:underline</span>.</p>
  </body>
</html>

Attributes

The <u> tag supports all Global attributes and Event attributes.

Practice

Practice

What is the function of the HTML <u> tag?