DEV Community

Cover image for How to Use Highlight Selected Text in Tailwind CSS
saim
saim

Posted on • Edited on • Originally published at larainfo.com

10 1 1

How to Use Highlight Selected Text in Tailwind CSS

In this section we will see how to use highlight text in tailwind css. we will see, highlight text color , highlight text background color with Tailwind CSS 3.

view

Example 1

Tailwind CSS highlight section text color.



<div class="max-w-xl selection:text-purple-900">
  <p>
    Tailwind CSS color selector lorem ipsum dolor I made my way past the breakers
    a strange calm came over me
  </p>
</div>


Enter fullscreen mode Exit fullscreen mode

tailwind css simple highlight selected text

Example 2

Tailwind CSS highlight section background color.



<div class="max-w-xl selection:bg-purple-600">
  <p>
    Tailwind CSS color selector lorem ipsum dolor I made my way past the breakers
    a strange calm came over me
  </p>
</div>


Enter fullscreen mode Exit fullscreen mode

tailwind css background highlight selected text color

Example 3

Tailwind CSS highlight selection background color and text color.



<div class="max-w-xl selection:bg-purple-300 selection:text-purple-900">
  <p>
    Tailwind CSS color selector lorem ipsum dolor I made my way past the breakers
    a strange calm came over me
  </p>
</div>


Enter fullscreen mode Exit fullscreen mode

tailwind css highlight text color

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay