HTML Reference ยท Inline Text
The <u> element
Reference for the HTML <u> element: non-textual annotations such as spelling-error marks or proper names in Chinese, why to avoid it for emphasis, and technical details.
The <u> element marks text with an unarticulated, non-textual annotation: a visual note whose meaning is understood from context rather than spelled out. The typical examples are a wavy line under a misspelled word, or the proper-name mark used in Chinese text. Browsers underline it by default.
<p>I received your <u class="typo">mesage</u> yesterday.</p>
Try it
The first paragraph restyles <u> as a red wavy line, a familiar sign of a spelling mistake. In the second, the default underline marks a proper name (Confucius), a convention in some Chinese typography.
Attributes
This element has no attributes of its own. It accepts the global attributes.
Usage notes
- Underlines look like links. Readers expect underlined text on the web to be clickable. Unless the context makes the annotation obvious, restyle
<u>(as in the spell-check example) so it can't be mistaken for a link. - Not for emphasis or titles. Use
<em>for stress,<strong>for importance,<cite>for a work's title and<mark>for highlighting. - Not for decoration. To underline text purely for style, use CSS
text-decoration: underlineon a meaningful element. - Accessibility. Screen readers don't announce
<u>, so the annotation is visual only. If a reader needs to know a word is misspelled, say so in text or with ARIA (for examplearia-invalid="spelling"on an editable field). - History. In older HTML,
<u>meant "underline" and was deprecated. HTML5 brought it back with the narrower meaning described here.
Technical summary
| Content categories | Flow content, phrasing content, palpable content |
| Permitted content | Phrasing content |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts phrasing content |
| Implicit ARIA role | generic |
| DOM interface | HTMLElement |
| Default display | inline (with text-decoration: underline) |
Browser support
Supported in every browser.
Related
<mark>โ highlighted for relevance<em>โ stress emphasis<s>โ no longer accurate- Lesson: Formatting Text
- Lesson: Deprecated and Obsolete Features