The <u>
tag in HTML is used to underline text. It visually emphasizes content by adding a line beneath the text, often to highlight important information or specific terms.
📌 What Is the <u>
Tag?
- The
<u>
element applies an underline style to enclosed text. - It is an inline element.
- Historically,
<u>
was used purely for presentation, but in HTML5, it has a more specific semantic meaning related to non-textual annotations. - Browsers render
<u>
text with an underline by default.
✅ Basic Syntax
<p>This is an <u>underlined</u> word.</p>
🧩 Semantic Meaning in HTML5
In modern HTML5, the <u>
tag represents text with an unarticulated annotation, which means:
- Underlined text that is not a hyperlink.
- It can represent proper names in Chinese text or misspelled words.
- It differs from emphasis tags like
<em>
or<strong>
.
🧪 Example: Underlined Text
<p>Please read the <u>terms and conditions</u> carefully.</p>
🎨 Styling with CSS Instead of <u>
For purely visual underlining, CSS is preferred:
<span style="text-decoration: underline;">Underlined text with CSS</span>
Or in CSS:
.underline {
text-decoration: underline;
}
And HTML:
<p class="underline">This text is underlined using CSS.</p>
⚠️ When to Use <u>
- Use
<u>
for semantic underlining, such as annotations or non-standard emphasis. - For links, browsers automatically underline
<a>
tags. - For decorative underlining without meaning, prefer CSS
text-decoration
. - Avoid using
<u>
solely for styling if semantics are not relevant.
🏁 Summary
The <u>
tag underlines text and in HTML5 carries semantic meaning related to annotations. For purely decorative underlines, CSS is the modern and preferred method. Use <u>
when the underline adds meaningful context beyond simple styling.