Open In App

HTML u Tag

Last Updated : 21 Nov, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The HTML <u> tag is traditionally used to underline text. It signifies text that should appear distinct from the surrounding content, such as misspelled words or specific names in various languages. However, in contemporary web design, it is mainly used for stylistic purposes to draw attention to certain text.

Note: the <u> tag is part of HTML4.1, it has been deprecated in HTML5. Instead, CSS should be used to achieve underlined text.

HTML
<!DOCTYPE html>
<html>

<body>
    <p>GeeksforGeeks: A
        <u>computer science</u>
        portal for geeks
    </p>
</body>

</html>

Using CSS to Underline Text

HTML
<!DOCTYPE html>
<html>

<body>
    <p style="text-decoration: underline;">
        This is an example of underlined text using CSS.
    </p>
</body>

</html>

HTML <u> Tag – FAQs

What are the current semantic uses of the <u> tag?

In modern HTML, the <u> tag is used to represent non-textual annotations, like names in certain languages or misspellings, rather than for simple underlining.

Why was the <u> tag considered deprecated in HTML4?

In HTML4, the <u> tag was considered deprecated because it was seen as a purely presentational element, mixing content with styling. HTML5 reintroduced the tag with updated semantics.

What are the differences between the <u>, <i>, and <b> tags?

The <u> tag is used for underlining, while the <i> tag indicates text that is styled differently for emphasis or for non-textual content, and the <b> tag indicates text that should be stylistically bolded. All three have semantic meanings in modern HTML.

Is the <u> tag the same as the text-decoration: underline; CSS property?

Functionally, both can underline text, but the <u> tag has semantic meaning in HTML5, while the text-decoration: underline; CSS property is purely for styling.

Can I nest the <u> tag within a <p> or <div> tag?

Yes, the <u> tag can be nested within any inline or block-level element like <p>, <div>, or <span>.

Does the <u> tag affect the line height or spacing of text?

No, the <u> tag only underlines the text and does not directly affect line height, spacing, or other layout properties.


Next Article

Similar Reads

three90RightbarBannerImg
  翻译: