Languages
[Edit]
EN

CSS - how to change text selection color

0 points
Created by:
Jan-Alfaro
341

In this article, we would like to show you how to change text selection color using CSS.

Quick solution:

::selection {
  color: red;
  background: yellow;
}

 

Practical example

In this section, we present a practical example of how to change text selection color.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
  <head>
    <style>

      ::selection {
        color: red;
        background: yellow;
      }

    </style>
  </head>
  <body>
    <p> some text... </p>
  </body>
</html>
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join