Text Underline in Tailwind CSS

Last updated on May 9, 2022 Pennywise Loading... Post a comment

In Tailwind CSS, you can add an underline to text by using the underline utility. You can also control the offset (the distance between text and the line) of a text underline by using underline-offset-{option} classes. {option} can be: auto, 0, 1, 2, 4, 8.

Example 1

Screenshot:

The code:

<body class="p-20">
    <h1 class="underline text-5xl">Hello World</h1>
    <br/>
    <h1 class="underline underline-offset-8 text-4xl">Goodbye World</h1>
    <br />
    <p class="underline underline-offset-0 text-indigo-500">Have a nice day</p>
</body>

Example 2

This example demonstrates how to show an underline when hovering a link.

Preview:

The code:

<body class="p-20">
    <a class="text-blue-600 text-2xl hover:underline" href="https://www.kindacode.com">Welcome to
        KindaCode.com</a>
</body>

Further reading:

You can also check out our CSS category page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You May Also Like