HTML CSS examples for CSS Selector:selection
The ::selection selector selects the selected part within an element.
::selection selector can only apply the following attribute:
Change the selected text color
<!DOCTYPE html> <html> <head> <style> ::-moz-selection { /* Code for Firefox */ color: red; background: yellow; } ::selection {<!--from w w w. j av a 2 s . co m--> color: red; background: yellow; } </style> </head> <body> <h1>Select some text on this page:</h1> <p>This is a paragraph.</p> <div>This is some text in a div element.</div> </body> </html>