Hi there! I'm Brandon Cash. I enjoy blogging about new Web technologies and other Web-related things.

CSS Tip: Styling Selected Text

We’ve all seen it—you’re on a page with a really amazing design, and select some text for some reason or another.  The selected text is then styled with some default background color, clashing with the amazing design.

Naturally, there is a CSS solution.  WebKit and Opera developers can use the ::selection pseudo element, and Mozilla developers can use ::-moz-selection.  Here is an example which changes the background color of all selected elements to a very translucent white:

*::selection {
    background-color: rgba(255, 255, 255, 0.1);
}

No longer does your highlighted text need to clash with your design!

Posted 1 year ago

About Me

I am a freelance Web developer and designer from Springfield, Missouri. Sometimes I like to do crazy Web experiments.

Twitter

What's this madness? You've reached the end of the page!
Next post. → ← Previous post.