You are currently viewing How to change the selection highlight color for specific sections or the whole website?

How to change the selection highlight color for specific sections or the whole website?

Change the highlight color of selection of your website to any color and also use the second CSS to add specific selection highlight color to your desired sections. 

				
					/*Change selection highlight color of your whole website*/

::selection {
background: blue;
}
				
			

You can change .main to any desired CSS class.

				
					/* Change selection highlight color of elements with CSS class "main"*/

.main::selection {
  background: red !important;
}

.main h1::selection,
.main h2::selection,
.main h3::selection,
.main h4::selection,
.main h5::selection,
.main h6::selection,
.main p::selection {
  background: red !important;
}

				
			

Leave a Reply