×

HTML <u> tag

Underline Element/Tag:

The u tag in html is used to specify the important text or phrase by underline. In earlier HTML versions, this element was known as the "Underline" element, and it is still occasionally used inadvertently in this manner.

You can also use a style with the CSS text-decoration attribute for underlying text.

The u element may be used for a variety of annotations, including correcting spelling errors, highlighting proper names in Chinese text, and so on.

You shouldn't use the u character to visually underline text or to denote book titles.

It is a closed tag that means ending tag is required to close this tag. This tag is represented as <u> tag in html documents

Syntax:

<body>
<p>
……………….
<u>……………. </u>
……………… 
</p>
</body>

Example:

Html:

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This attribute can be used to highlight <u>speling</u>errors, so that the user can <u>corect</u> them all.
</p>
</body>
</html>

Css:

p {
font: 1rem 'Fira Sans', sans-serif;
}
u {
text-decoration: #f00 wavy underline;
}

Output:

Html u Tag

Attributes

Only global attributes are used with this tag.

Global attributes are being supported by this tag. All the event attributes in HTML are also supported by this tag.

Other elements same as U tag:

<em>

This attribute is used to denote stress emphasis.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <em>paragraph includes </em> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<b>

This attribute is used to draw attention to text.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <b>paragraph includes </b> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<mark>

This attribute is used to mark key words or phrases.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <mark>paragraph includes </mark> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<strong>

This characteristic is used to denote the relevance of the text.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <strong>paragraph includes </strong> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<cite>

If you want torepresent the titles of books or other publications, then you can use this tag in HTML document.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <cite>paragraph includes </cite> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<i>

In Western writings, this tag is basically used for indicating technical terminology, transliterations, viewpoints, or vessel names.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <i>paragraph includes </i> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

<ruby>

You can add textual annotations with the help of ruby tag in the HTML document.

Utilize the underline value of the text-decoration attribute to impose an underlined look without any semantic significance.

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This <ruby>paragraph includes </ruby> a Wrnogly spelled word.
</p>
</body>
</html>

Output:

Html u Tag

Examples of U tag:

Example 1: For Indicating an error in spelling:

This example uses the <u> element and css code to show a sentence with a spelling problem.

HTML:

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
This paragraph includes a 
<u class="spelling">
Wrnogly
</u>
spelled word.
</p>
</body>
</html>

When the word "wrongly" is spelled incorrectly, the HTML uses the u element with the spelling class.

CSS:

u.spelling 
{
text-decoration: red wavy underline;
}

This CSS specifies that when the class spelling is used to style the u element, then its text is shown by the red underline. This is a typical style for typographical problems. Red dashed underlining can be used to illustrate another typical design.

Output of above code:

Html u Tag

Avoiding u Tag

Most of the times, if you want to avoid u tag, then you can use few instances that demonstrate various situations for specifying something.

Non-semantic underlines

You can use a <span> tag with the text-decoration attribute set to "underline" to highlight text:

HTML:

<!DOCTYPE html>
<html>
<head>
<tile> html u tag </title>
</head>
<body>
<span class="underline">
Today's Episode
</span>
<br>
Almighty gamer as an ultra-instinct guy
</body>
</html>

CSS:

.underline 
{
text-decoration: underline;
}

Output:

Html u Tag

Presenting a book title

You can use cite tag instead of u tag for indicating the titles.

Using the cite element

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
The class read 
<cite>
Moby Dick
</cite>
in the first term.
</p>
</body>
</html>

Result:

Html u Tag

Styling the cite element:

The text is shown in italics by the default style of cite element.

HTML:

<!DOCTYPE html>
<html>
<head>
<title> html u tag </title>
</head>
<body>
<p>
The first book is
<cite>
The secret
</cite>
in the early ages.
</p>
</body>
</html>

CSS:

cite {
font-style: normal;
text-decoration: underline;
}

Output:

Html u Tag

Browser support:

List of browsers that support html u tag are given below:

Chrome: Yes

Microsoft Edge: Yes, version 12 needed

Firefox: Yes, version 1 needed

Safari: Yes

Opera: Yes


Related Topics

HTML Form Action

The <form> tag has an attribute named action that contains a URL. The HTML action attribute defines the webpage URL on which you want to send the data after submitting...

4 minutes read.

HTML Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

4 minutes read.

HTML Hide Element

The HTML hide element is used to hide the element. We place the hidden attribute inside those elements which we want to hide. The hidden attribute is a Boolean attribute. The...

3 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

Difference between HTML and DHTML

Introduction to HTML HTML stands for Hypertext Markup Language. It is a standard web language used to create web pages and applications. HTML is used to define the structure and content...

4 minutes read.

HTML Basic Tags

Heading Tags: This tag represents the document header. It is said to be a good practice if every document starts with Heading. Heading tags ranges from H1 to H6 i.e....

3 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

HTML <sub> tag

The sub element in HTML is used to describe one or more subscript texts. If The sub tag shows the text which is presented in a smaller font and below...

2 minutes read.

HTML Nested Table

HTML nested table refers to a table that is created inside another table. The table is in the form of rows and columns. From left to right are called horizontal rows,...

5 minutes read.

HTML Canvas

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

3 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

HTML Font Size

The HTML <font> tag uses the size attribute to specify the size of the text. We can set the size attribute’s value from 1 to 7. The default size of...

4 minutes read.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

Design a tribute page using HTML and CSS

A tribute page is a webpage based on a person who inspired us in our life. In this article, we will create a webpage of Mahatma Gandhi. We are going...

5 minutes read.

HTML <section> tag

The section element in HTML is used to define sections in a document. Syntax of Section Tag: <body> <h1>……….</h1> <section> <h2>……….</h2> <p> …………………………</p> </section> <section> <h2>………..</h2> <p>…………………………. <p> </section> </body> Examples of Section Tag Example 1: In this example, we use the HTML "section" element...

3 minutes read.

HTML Data Tag

HTML Data Tag: The HTML < data > tag is used to transmit its content to a machine-readable version. The data are presented in a particular format. It is useful...

3 minutes read.

HTML Charsets

In this tutorial, we are going to discuss about the charsets in the HTML. The letters, numbers, and several other symbols are shown correctly by the web browser. All of this...

2 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.