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.
1 2 3 4 5 6 | ::-moz-selection{ background:#93B805;color:#fff } ::selection{ background:#93B805;color:#fff } |
This property is not supported by IE
All done!!
cheers!












Comments
It’s very interesting article. Thank you for information.
Good to discover that there are blog owners that care about their blogs and not write all kind of useless stuff but rather try to sustain it clean and worthy for the sake of their readers. You’ve done a good job and i thank you for that and as well for not shocking me with unuseable garbage and spam.Thank You
It is hard to find good blogs nowadays, I am glad I came across yours and I look forward to read your next post. Best Regards!
What a great resource!
This is a great source and i would like to share all this to my twitter fans and followers.
Thanks for this nice trick! I’m trying to teach myself how to design a website, and I was searching for good tips for CSS and I came across this great article. it’s short, interesting and says everything you need to know.
Thank you!