March 5, 2012

Custom Highlight Failing on Website

Question by Matt

I’ve noticed on a lot of sites with custom highlight colors, if you press CTRL + A, the default highlight color, blue, always manages to creep through. Why is that? In making my own site, I have my own custom color too, but I also have the same problem. Does anyone know how to keep this from happening?

http://www.smashingmagazine.com/, http://www.admixweb.com/ are both examples of the CTRL + A problem.

Answer by Starx

Selection styles are mostly browser dependant, and might not be customisable in all browsers. Here is an example of how to configure such styles.

p.normal::selection {
    background:#cc0000;
    color:#fff;
}

p.moz::-moz-selection {
    background:#cc0000;
    color:#fff;
}

p.webkit::-webkit-selection {
    background:#cc0000;
    color:#fff;
}

Such styling are very risky to use and should not be depended upon.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!