Thursday, August 11, 2022

How to use the CSS::selection

   
CSS Selection Property

CSS:: selection is used to define the style for the user selecting on the webpage. P tag used on the webpage you can add the custom selection style to that particular tag. User select that tag custom style will appear what you gave for that particular thing.

If you want to add a custom to-enter page at the time of user selection you can give a custom style on the body tag. Now see the example and sample code below.

List of Css property work on selection:

  • color
  • background-color
  • text-decoration and its associated properties
  • text-shadow
  • stroke-color, fill-color and stroke-width

CSS:

p:selection{
color:#ffffff;
background-color:#ff0000;
}

HTML:

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>

OUTPUT

Selec the text you will see the read background and text color as white.

No comments:

Post a Comment