How To, HTML/CSS

Selection in CSS | CSS ::selection

Written by Bikash · 37 sec read >

How To Change Text Selection Color

Selection in CSS ::selection is a selector of CSS, that highlighted the text, which is selected by the user.

For example, a part of a web page that is selected by the user using any device like a mouse or any pointing device.

See an image (selection CSS), also I provide the complete demo,

Selction in CSS | CSS ::selection

When you use ::selection that can change the background and foreground of the text of selected text.

CSS Syntax | ::selection

On the below example, we change the background text color using ::selection CSS property,

The above ::selection CSS code supported by all the browser but for Mozilla firefox, we change the code,

How to disable text selection highlighting

Here is a code for disable text selection highlighting,

CSS ::selection Live Demo

See the Pen CSS ::selection PHPCODER.TECH by Bikash Panda (@phpcodertech) on CodePen.

Also Check:

Happy Coding..!

Was this article helpful?
YesNo
Written by Bikash
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP. Profile