Use CSS ::selection to change background in selection - HTML CSS CSS Property

HTML CSS examples for CSS Property:background

Description

Use CSS ::selection to change background in selection

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

::selection{<!--from   www.ja v  a 2s  . co  m-->
   background: green;
   color:white;
}


      </style> 
 </head> 
 <body> 
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p> 
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p> 
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>  
 </body>
</html>

Related Tutorials