change color of text selection css code example
Example 1: custom selection color css
::selection {
color: #000000;
background-color: red;
}
/* for firefox */
::moz-selection {
color: #000000;
background-color: red;
}
Example 2: change highlight color html
::-moz-selection { /* Code for Firefox */
color: red;
background: yellow;
}
::selection {
color: red;
background: yellow;
}
Example 3: how to change selection color of text in css
::-moz-selection { /* Code for Firefox */
color: red;
background: yellow;
}
::selection {
color: red;
background:
yellow;
}
Example 4: css mark color
<style>
mark {
background-color: yellow;
color: black;
}
</style>
<mark>Highlighted text!!</mark>
Example 5: how to add a selection in css
<select>
<option value="tesla">Tesla</option>
<option value="volvo">Volvo</option>
<option value="mercedes">Mercedes</option>
</select">