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

Share

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!

  • January 23, 2010
8 Best Free Stock Video Websites for Tiktok, Reels, and Shorts Top 5 PHP Frameworks: Fast and Secure