how to change the selected text color in css code example

Example 1: change highlight color html

::-moz-selection { /* Code for Firefox */
  color: red;
  background: yellow;
}

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

Example 2: how to change selection color of text in css

::-moz-selection { /* Code for Firefox */
  color: red;
  
  background: yellow;
}

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

Example 3: css mark color

<style>
mark { 
  background-color: yellow;
  color: black;
}
</style>

<mark>Highlighted text!!</mark>

Tags:

Css Example