text-underline-position

CSS text-underline-position Property

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 is only partially supported by Chrome .

For maximum browser compatibility, extensions such as -webkit- for Safari, Google Chrome, and Opera (newer versions) are used with this property.

类目类目
Initial Valueauto
Applies toAll elements.
InheritedYes.
AnimatableNo.
VersionCSS3
DOM Syntaxobject.style.textunderlinePosition = “under”;

Syntax

Syntax

text-underline-position: auto | under | left | right | above | below | auto-pos | initial | inherit;

Example of the text-underline-position property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p {
        text-decoration: underline;
        -webkit-text-underline-position: auto;
        -ms-text-underline-position: auto;
        text-underline-position: auto;
      }
    </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:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p {
        text-decoration: underline;
        -webkit-text-underline-position: under;
        -ms-text-underline-position: under;
        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

Values

ValueDescription
autoThe browser uses its own algorithm to place the line at or under the alphabetic baseline.
underForces the underline to be placed under the element’s text content.
leftForces the element to be placed on the left side of the text in the vertical writing-mode.
rightForces the element to be placed on the right side of the text in the vertical writing-mode.
aboveForces the line to be above the text.
belowForces the line to be below the text.
auto-posWorks the same as auto value.
initialMakes the property use its default value.
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部