×

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 <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML,...

3 minutes read.

Div Tag in HTML

In HTML, ‘div’ is a tag that specifies division or section in HTML document. But before going in detail of it, let’s first understand about tags in HTML. The tag...

8 minutes read.

Html &lt;datalist >Tag

The autocomplete feature in HTML files is provided by the <datalist> tag. It can be used in conjunction with an input tag to enable users to quickly fill out form...

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.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

CSS Clearfix

CSS Clearfix: A clearfix (or clear float) in CSS is for a component to clear or fix the child component, so we don’t need to insert additional markup. The clear...

4 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.

HTML Audio

HTML AUDIO: HTML5 provides a method to embed the audio file into a webpage by using HTML5. Before HTML5 audio files is used to play on the browser with the help of...

1 minute read.

HTML Forms

Forms are required when we want to collect data from the user. Html forms consists of different fields to take user inputs such as: input, text area, checkbox, password, radio...

4 minutes read.

HTML References

BASIC HTML TAGS TAGS DESCRIPTION <!DOCTYPE> Defines Document Type <html> Defines Html document <head> Defines Header of document <title> Defines Title of document <body> Describe all the content of document <h1> to <h6> Defines Html Heading <p> Write Paragraph in this tag <br> Line break <!--...--> Comment in Html FORMATTING TAGS TAGS DESCRIPTION <abbr> Defines...

3 minutes read.

HTML <span> tag

The span tag in HTML is used as an inline container element to mark up a specific or special chunk of a text or a section of a page. If you...

2 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.

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 Youtube

<object> element: It embed the object within the HTML documents and embed plug-ins such as Java applets, PDF readers, Flash Players etc in web pages. Example: <object width="100" height="100" data="bookmark.swf"></object> <embed> element: It defines an embedded...

1 minute read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML Frames

Frames in Html is used to divide the browser into different sections where each section can load different Html documents. Collection of frame is known as Frameset. Creating frames:We use frameset...

2 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 Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

HTML <strong> tag

The strong element in HTML is used to display the real significant information in bold so that the user or reader will understand it easily. Syntax: <p> <strong>………… </strong> </p> Example Here, we will demonstrate how to...

2 minutes read.

HTML &lt;blink> Tag

In HTML, the blink tag is used to create the text which flashes. The blink tag is an inline element in HTML. It is observed that the blink tag used...

2 minutes read.