Languages
[Edit]
EN

CSS - how to change text selection color

0 points
Created by:
Jan-Alfaro
711

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>
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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