Webflow tip

Change the color of highlighted text on your Webflow site using CSS

Jaroslav Dlask
Jaroslav Dlask
July 12, 2022
1 min
Change the color of highlighted text on your Webflow site using CSS

Changing a selection color of a highlighted text can improve the look of your site. Yet it is very easy to implement using the ::selection selector in CSS.

1) Open your project settings

Webflow project settings
Project settings

2) Switch to a custom code tab

Custom code tab

3) Copy this code snippet & paste it at the end of the <head> tag

Adding a code at the end of the <head> in your project settings will affect your entire website. This way we make sure that the highlighted text color is the same on all pages. However, if you wish to have a different selection color on the various pages, you can override it by adding this code with different parameters to the page settings head code. Make sure you put the code in between <style> and </style> tags.

<style>
::selection {
 color: #000000; background: #0050f0;
}
</style>
Webflow Head code
Head code

4) Edit the color and background parameters

Replace the #000000 hex code to change the text color and #0050f0 for the background color. Make sure that the colors have sufficient contrast. You can use this awesome tool to check the contrast. Make sure that you hit the green save button. Last but not least publish your changes.