开发者

In-browser default selected text color - What is it?

开发者 https://www.devze.com 2022-12-15 21:50 出处:网络
Supposing no CSS, javascript or other HTML trickery, how does the browser determine the color of the text and background for selected text?

Supposing no CSS, javascript or other HTML trickery, how does the browser determine the color of the text and background for selected text?

For example, standard white background (#FFFFFF or RGB=255,255,255) with black text (#000000 or RGB=0,0,0) when selected with invert the colors (i.e. black background, white text). How are other colors chosen? For example, when writing a question on this site, the right sideba开发者_如何学运维r has an area "How to ask" with background #FFEFC6 and text #AE0000, which when selected become #3399FF and #FFFFFF respectively.

I would like to know how this is determined (is there an algorithm or just defaults) and is this the same across browsers?


I'd agree with Joshua that the colors come from the system, but I'd disagree about CSS, for example, CSS-Tricks:

::selection { background: #ffcc89; color: #222; }
::-moz-selection { background: #ffcc89; color: #222; }

For more info, see Quirksmode on selection styles.


In my recall, the foreground and background colors are read from system colors and cannot be controlled by CSS.


I believe that each operating/windowing system has its own algorithm. On many, you can select from a few different schemes. It will NOT be the same across all browsers.

For example, in Safari on my Mac, selecting black text on a white background results in a blue rectangle around black text.

0

精彩评论

暂无评论...
验证码 换一张
取 消