Tailwind CSS tutorial #27: Text Underline Offset
Tags: tailwindcss, tutorial, beginners, css
Published: 2022-12-04 17:21:17

In the article, we will go into detail on how to use `Text Underline Offset`.

## Text Decoration
**Format**
> `underline-offset-{width}`

| Tailwind Class | CSS Property |
| ------ | ------ |
| `underline-offset-auto` | `text-underline-offset: auto; `|
| `	underline-offset-0	` | `text-underline-offset: 0px; `|
| `	underline-offset-1	` | `text-underline-offset: 1px; `|
| `	underline-offset-2	` | `text-underline-offset: 2px; `|
| `	underline-offset-4	` | `text-underline-offset: 4px; `|
| `	underline-offset-8	` | `text-underline-offset: 8px; `|


# Setting the underline offset
Use the underline-offset-{width} utilities to change the offset of a text underline.

## **Code**
```html
 <ul class="container mx-auto divide-y divide-gray-400 divide-dotted" style="font-family: Raleway">
  <li class="flex items-center justify-between px-4 py-2">
    <ul class="underline underline-offset-1">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">underline-offset-1	</div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <ul class="underline  underline-offset-2	">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">underline-offset-2	</div>
  </li>
    <li class="flex items-center justify-between px-4 py-2">
    <ul class=" underline underline-offset-4		">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">underline-offset-4	</div>
  </li>
    <li class="flex items-center justify-between px-4 py-2">
    <ul class=" underline underline-offset-8		">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">underline-offset-8	</div>
  </li>
</ul> 
```
**Full code:**
The overall code will be attached to [repo ](https://github.com/codewithshubhi/learn-tailwind-css/blob/main/Text%20Underline%20Offset.html)link.

**Overall Output**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dztemxb3r1f262if59y6.png)



**Resources:**
[tailwind.css](https://tailwindcss.com/docs)

Thank you for reading :), To learn more, check out my blogs on [Flex Direction](https://dev.to/shubhicodes/tailwind-css-tutorial-13-flex-direction-i8j), [Hackathons](https://dev.to/shubhicodes/all-about-hackathons-how-to-find-participate-win-42kk) and [Flex Wrap](https://dev.to/shubhicodes/tailwind-css-tutorial-14-flex-wrap-kee).
If you liked this article, consider following me on [Dev.to](https://dev.to/shubhicodes) for my latest publications. You can reach me on [Twitter](https://twitter.com/heyShubhi).

Keep learning! Keep coding!! 💛