Theme & Front End CSS Beginner

Brand-Coloured Text Selection

Change the highlight colour when visitors select text, from the browser's default blue to your brand colour.

Tested on WordPress 7.1 No plugin needed Updated
style.css 4 lines
::selection {
	background: #6F58CA;
	color: #fff;
}

Where to add this

Recommended Additional CSS Appearance → Customize → Additional CSS, or your page builder's global CSS.
Child theme At the end of your child theme's style.css file.
A code snippets plugin As a CSS snippet set to load on the front end.

When someone highlights text on your site, the browser uses its own blue. Matching it to your brand is a tiny detail that makes a site feel considered.

How it works

The ::selection pseudo-element styles whatever text is currently selected. Only a few properties work on it, mainly color, background and text-shadow.

Things to watch

  • Keep enough contrast between the two colours, at least 4.5 to 1, so selected text stays readable.
  • To use a different colour inside dark sections, add a more specific rule such as .dark-section ::selection.

How to test it

Select some text on any page. The highlight should use your colours.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only