HTML <u> Tag โ Underlined Text
๐ Introduction
The <u> tag is used to display underlined text in HTML.
By default, it visually adds an underline under the text.
However, in modern HTML, <u> is not meant for emphasis. It is mainly used for:
- Marking misspelled words
- Proper names in some cases
- Stylistic or special text formatting
๐งฑ Syntax
<u>Underlined text</u>
๐ก Example
<!DOCTYPE html>
<html>
<head>
<title>U Tag Example</title>
</head>
<body>
<p>This is normal text.</p>
<p>This is <u>underlined text</u>.</p>
</body>
</html>
๐ฅ๏ธ Output Explanation
- Normal text appears regular
- Text inside
<u>appears underlined
๐ฏ When to Use <u>
Use <u> for:
- Highlighting spelling mistakes
- Special annotations
- Non-emphasis underline styling
Example:
<p>This word is <u>wrongly spelled</u>.</p>
โ ๏ธ Important Note (Modern HTML)
In older HTML, <u> was used for emphasis.
But today:
๐ Do NOT use <u> for importance or highlighting
๐ Use CSS instead if you only want decoration
โ๏ธ <u> vs <strong> vs <em>
| Tag | Meaning | Purpose |
|---|---|---|
<u> |
Underlined text | Visual/annotation |
<strong> |
Important text | Semantic importance |
<em> |
Emphasis | Semantic stress |
๐จ Better Modern Way (CSS)
Instead of <u>, you can do:
<p style="text-decoration: underline;">Underlined text</p>
โ More control โ Cleaner design practice
๐ซ Common Mistakes
- Using
<u>for emphasis โ - Using it like a heading โ
- Overusing underlines everywhere โ
๐งช Mini Exercise
Create a page with:
- A paragraph about learning English or HTML
- Underline:
- One mistake word
- One important term