Condition CSS based on OS

Viewed 92

I'm working on an HTML page for a client, this page contains a table with multiple line like this:

<div id="content">
    <div class="line">toto</div>
    <div class="line">titi</div>
    ...
</div>

and my client wants on a click in a line to select this line, well quite simple but he wants a specific color depending on system.

On Windows, it is simple because you only have one color for selecting text (that i'm aware of) but on Mac, you can modify this color in your settings, you can make it green, red or yellow instead of the usual blue.

So with CSS or Javascript (i use JQuery), can i get this color ?

Bonus Question : if the user change this color in his settings, can something tell me this so that i can update my CSS ?

2 Answers

Unfortunately you can't get the specific color value of the highlight selection when it's the OS's default in CSS, but you are totally free to change it as you wants.

A workaround could be highlighting programmatically the text on the desired div, which would be, by default, the color defined by the system.

If you think this would be a satisfactory solution, take a look here to see some code sample.

I imagine that is imposible because the Operational System allow the user change the color pallet under your preferences. The browser may not access this kind of information.

I hope i am wrong, but for now, i understand that is imposible.

OR

You could configure an specific CSS file for each operational system and it will be prefixed, so you can get the Operational System iformation and select the css file.

Related