HTML Code for Underlining

Understanding the <u> Tag

The <u> tag in HTML is used to underline the text within the tag. It is a non-semantic tag, meaning it does not convey any specific meaning about the content it is applied to.

Styling Underlined Text with CSS

While the <u> tag is the traditional way to underline text in HTML, it is generally recommended to use CSS to style text and apply underlines. This allows for more flexibility and control over the appearance of the underlined text.

Best Practices for Using Underlines

Underlines should be used sparingly and consistently to avoid confusing users, as underlined text is commonly associated with hyperlinks. It is important to ensure that underlined text is easily distinguishable from hyperlinks to prevent any user experience issues.

Example Code

  <p>This is a <u>sample</u> text.</p>

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free