CSS text-underline-position Property
Use the text-underline-position CSS property to specify the position of an underline for the element. See property values and try examples.
The text-underline-position property specifies the position of the underline on the element with the text-decoration "underline" value specified.
The text-underline-position property is widely supported in all modern browsers.
| Initial Value | auto |
|---|---|
| Applies to | All elements. |
| Inherited | Yes. |
| Animatable | No. |
| Version | CSS3 |
| DOM Syntax | object.style.textUnderlinePosition = "under"; |
Note: In JavaScript, CSS properties with hyphens are converted to camelCase (e.g., text-underline-position becomes textUnderlinePosition).
Syntax
CSS text-underline-position values
text-underline-position: auto | [ under || left || right || above || below ] | initial | inherit;Example of the text-underline-position property:
CSS text-underline-position code example
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
p {
text-decoration: underline;
text-underline-position: under;
}
</style>
</head>
<body>
<h2>Text underline-position property example</h2>
<p>Lorem Ipsum is simply dummy text...</p>
</body>
</html>Result

Example of the text-underline-position property with the "under" value:
CSS text-underline-position under value example
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
p {
text-decoration: underline;
text-underline-position: under;
text-decoration-color: #1c87c9;
font-size: 25px;
}
</style>
</head>
<body>
<h2>Text underline-position property example</h2>
<p>Lorem Ipsum is simply dummy text...</p>
</body>
</html>Values
| Value | Description |
|---|---|
| auto | The browser uses its own algorithm to place the line at or under the alphabetic baseline. |
| under | Forces the underline to be placed under the element's text content. |
| left | Forces the underline to be placed on the left side of the text in the vertical writing-mode. |
| right | Forces the underline to be placed on the right side of the text in the vertical writing-mode. |
| above | Forces the line to be above the text. |
| below | Forces the line to be below the text. |
| initial | Makes the property use its default value. |
| inherit | Inherits the property from its parents element. |
Practice
Practice
Which statement is incorrect about text-underline-position property?