Changing The Style of Highlighted Text in Mozilla

There are several interesting style on Mozilla’s specific CSS. One of the most interesting trick is changing the style of the text when user highlighted the text using -moz-selection property.

Look the sample of code below:

[css]::-moz-selection{
background-color: #ff0000;
color: #fff;
}[/css]

now when user selected or highlighted any text, the background color will change to red (#ff0000) and the text color is white (#fff). I used that style on this site so simply highlighted any text here and see the result.

Do not forget that this is Mozilla’s specific CSS, so it won’t work on Internet Explorer. I hope this property will be included on CSS3 specification draft so more browser will support it.

Popularity: 34% [?]

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>