HTML <u> Tag

HTML Tag

HTML <u> Tag


In HTML 4.01 the <u> element was used to specify underlined text. In HTML 5, the <u> tag specifies text that is stylistically different from normal text, i.e., words or fragments of text that need to be presented differently. It could be misspelled words or proper nouns in Chinese.
The text in the <u> tag is being underlined (unless you style it otherwise).
This element should not be used just to underline the text because it is a deprecated HTML tag. For this purpose, use CSS text-decoration property set to "underline".

Syntax

The <u> element comes in pairs. The content is written between opening (<u>) and closing (</u>) elements.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
  </head>
  <body>
    <p>Here we used <u>the &lt;u&gt; element</u>.</p>
  </body>
</html>

Result

u tag example
See an example with CSS text-decoration property.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document.</title>
    <style>
      span {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <p>Here we used <span> CSS property text-decoration:underline</span>.</p>
  </body>
</html>

Result

text-decoration:underline example

Attributes

The <u> tag supports the Global attributes and the Event Attributes.

How to style <u> tag

Common properties to alter the visual weight/emphasis/size of text in <u> tag:?

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick. CSS text-transform Property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style

Coloring text in <u> tag:

  • CSS color property describes the color of the text content and text decorations
  • CSS background-color property sets the background color of an element.

Text layout styles for <u> tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signaled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <u> tag

  • CSS text-shadow property adds shadow to text.
  • CSS text-align-last property sets the alignment of the last line of the text.
  • CSS line-height property specifies the height of a line.
  • CSS letter-spacing property defines the spaces between letters/characters in a text.
  • CSS word-spacing property: Allow setting the spacing between words.
Reactions

Post a Comment

0 Comments

close