CSS trick to change the color of selected text on any web page

clipboard01-1850453

The easiest way to change the color of selected text on any web page is using pure CSS trick which you might not know. Working on some project , today , i find a trick to change the color of selected text. Whenever a person select a text , its color changes to defined color. For example, on my blog theme ,if you select some text you will notice green color in place of indigo. ( which is default color ). I simply added four lines of CSS and all it happens.

Here is the trick. Simply copy and paste the following CSS into your stylesheet and see the magic.

 
::-moz-selection{
background:#93B805;color:#fff
}
::selection{
background:#93B805;color:#fff
}

This property is not supported by IE

All done!!
cheers!

Scroll to Top