How to underline a text in HTML?
To underline a text in HTML, use the <u> tag. The <u> tag deprecated in HTML, but then re-introduced in HTML5. Now it represents a text different from another text stylistically, such as a misspelled word.
To underline a text, you can also use the style attribute. The style attribute specifies an inline style for an element. The attribute can be used with the HTML <p> tag, with the CSS property text-decoration.
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
Example
You can try the following code to underline text in an HTML page, using the <u> tag
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML u tag</title>
</head>
<body>
<h1>Heading</h1>
<p><u>This text will be underlined.</u></p>
</body>
</html>
Example
You can try the following code to underline text in an HTML page, using the CSS text-decoration property
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Text underline</title>
</head>
<body>
<h1>Heading</h1>
<p style="text-decoration: underline;">This text will be underlined.</p>
</body>
</html>