Typography

Text Decoration

Utilities for controlling the decoration of text.

Quick reference

Class
Properties
underlinetext-decoration-line: underline;
overlinetext-decoration-line: overline;
line-throughtext-decoration-line: line-through;
no-underlinetext-decoration-line: none;

Basic usage

Setting the text decoration

Control how text is decorated with the underline, no-underline, and line-through utilities.

Text Decoration - 图1

  1. <p class="underline ...">The quick brown fox ...</p>
  2. <p class="overline ...">The quick brown fox ...</p>
  3. <p class="line-through ...">The quick brown fox ...</p>
  4. <p class="no-underline ...">The quick brown fox ...</p>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:text-center to only apply the text-center utility on hover.

Text Decoration - 图2

Try hovering over the text to see the expected behaviour

Text Decoration - 图3

  1. <a href="#" class="no-underline hover:underline ...">Link</a>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:underline to apply the underline utility at only medium screen sizes and above.

  1. <p class="no-underline md:underline">
  2. <!-- ... -->
  3. </p>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.