{"id":311020,"date":"2020-05-18T13:55:47","date_gmt":"2020-05-18T20:55:47","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=311020"},"modified":"2021-08-02T11:15:54","modified_gmt":"2021-08-02T18:15:54","slug":"text-underline-offset","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/t\/text-underline-offset\/","title":{"rendered":"text-underline-offset"},"content":{"rendered":"\n

The text-underline-offset<\/code><\/strong> property in CSS sets the distance of text underlines from their initial position.<\/p>\n\n\n\n

.element {\n\u00a0 text-underline-offset: 0.5em;\n}<\/code><\/pre>\n\n\n\n

Once you apply an underline for an element using text-decoration<\/code><\/a> with the value of underline,<\/strong> you can say how far that line should be from your text using the text-underline-offset<\/code> property.<\/p>\n\n\n

Values<\/h3>\n\n\n
  • auto<\/code>: (Default) The browser will specify an appropriate offset for underlines.<\/li>
  • <length><\/code>: Any valid length with a specified unit (including negative values). This replaces any information in the font and the browser default.<\/li>
  • percentage<\/code>: Specifies the offset of underlines as a percentage of 1em in the element’s font.<\/li>
  • initial<\/code>: The default setting of the property, which is auto.<\/li>
  • inherit<\/code>: Adopts the underline offset value of the parent.<\/li>
  • unset<\/code>: Removes the current offset from the element.<\/li><\/ul>\n\n\n

    Demo<\/h3>\n\n\n

    In the following demo you can change the value of text-underline-offset<\/code> to see how it affects the text decoration of the element:<\/p>\n\n\n\n