W3docs

HTML <u> Tag

The HTML <u> tag marks a span of text with an unarticulated, non-textual annotation, such as a misspelled word. Learn its HTML5 meaning with examples.

The HTML <u> tag represents a span of inline text with an unarticulated, non-textual annotation. That is a deliberately broad definition: it marks text that should be set apart for a reason that doesn't fit any other element, but without saying why in the text itself. The browser renders that annotation as an underline by default — but the underline is just a visual cue, not the point of the element.

This is a common misconception worth clearing up: in HTML5 the <u> tag is not deprecated, and it does not simply mean "underline this." It was redefined away from its old, purely presentational HTML 4 meaning. If all you want is an underline for styling, that's a CSS job, not an <u> job.

The two canonical use cases from the HTML specification are:

  • Marking a misspelled word, the way a spell-checker draws a squiggly line under it.
  • Marking a proper name in Chinese text (the proper-name mark, an annotation convention in Chinese typography).

In modern apps, the most legitimate place you'll reach for <u> is a rich-text editor that needs to record a spell-check or proper-name annotation as semantic markup rather than as styling.

Warning

Underlined non-link text is easily mistaken for a hyperlink. Most users read underlines as "this is clickable." Use <u> only when you genuinely mean a non-textual annotation, and consider restyling it (for example with a dotted or wavy underline) so it doesn't look like a link. Never underline text just for emphasis — use <em> or <strong> for that. For purely decorative underlines, use the CSS text-decoration property instead.

In most situations a different, more specific element communicates your intent better than <u>:

  • <em> for stress emphasis,
  • <strong> for text of strong importance,
  • <mark> for highlighting relevant phrases or keywords,
  • <ins> for text that has been inserted into a document,
  • <b> for drawing attention without conveying importance,
  • <cite> for the title of a cited work,
  • <i> for technical terms, foreign phrases, or thoughts.

If you want to add a textual annotation (such as a pronunciation guide), use the <ruby> tag instead.

Syntax

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

Example: marking a misspelled word

A common, spec-aligned use is flagging a spelling error. A class lets you restyle the default underline as a wavy red line, the way editors show spelling mistakes:

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
    <style>
      .spelling-error {
        text-decoration: red wavy underline;
      }
    </style>
  </head>
  <body>
    <p>The word <u class="spelling-error">teh</u> is misspelled.</p>
  </body>
</html>
Result

Example: annotating a proper name in Chinese text

The other canonical use is the Chinese proper-name mark, where <u> annotates a word as a proper noun:

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
  </head>
  <body>
    <p><u>李白</u>是著名的诗人。</p>
  </body>
</html>
Result

Example: the default rendering

By default, browsers underline the content of a <u> element:

<!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>

Example of the CSS text-decoration property:

If you only want an underline for visual styling, reach for CSS rather than <u>:

<!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 does the HTML u tag represent in HTML5?
What does the HTML u tag represent in HTML5?
Was this page helpful?