1/*Term: css text highlight*/
2
3/*This uses the element ::selection, which is as far as i
4know only supported by Google Chrome so far. This is not
5a problem though, since other browsers will simply keep
6the regular highliting styles.*/
7
8/*Example*/
9::selection {
10 background-color: #000; /*Highlight Color*/
11 color: #fff; /*Text Color*/
12}
1For HTML5: (with 'mark' tag)
2
3<p>Do not forget to buy <mark>milk</mark> today.</p>
4
5In CSS file: (To customize highlight)
6
7mark {
8 background-color: yellow;
9 color: black;
10}
1<style>
2mark {
3 background-color: yellow;
4 color: black;
5}
6</style>
7
8<mark>Highlighted text!!</mark>
1/* Now supported by all major browsers */
2
3::selection {
4 background-color: #000 /* Selection highight color */
5 color: #FFF /* Optional colour change of text that is being selected */
6}