fatBuzz of Fatbuzz Development Team
12/18/2017 - 10:30 AM

Styling Selection text in CSS

Add selection.css to the sites main css file.

Within the selection selector, color and background are the only properties that work.

Note: the selectors are not combined, even though the style block is doing the same thing. It doesn't work if you combine them.

/* This will work */
p::selection {
  background: #ffb7b7; /* WebKit/Blink Browsers */
}
p::-moz-selection {
  background: #ffb7b7; /* Gecko Browsers */
}

/* Combining like this WILL NOT WORK */
p.yellow::selection,
p.yellow::-moz-selection {
  background: #fff2a8;
}