Why cannot use body::selection, when i want anything that can highlight to be the color i desired, anything include p img li h1
Examples here
Now i want everything highlight to be RED color, but i am using body::selection, it never work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to apply the selection background to all elements, omit the type selector:
And for that matter, add
::-moz-selectionso it works in Firefox too:It was never decided how exactly the styles you set for
E::selectionfor any elementEshould propagate to descendants ofE. There’s a much more in-depth discussion in the www-style mailing list. It is also for this reason that::selectionhas been totally dropped from CSS3 with the latest LC revision of CSS3 UI; see this section, which says:My best guess is that browsers (at least Firefox) just don’t apply the same rule to descendant elements. So if you apply the pseudo-element to
body, then onlybodytext will have the custom selection background; everything nested inside it won’t have the selection background.