HTML and CSS Reference
In-Depth Information
1.11 Highlighting Text for Reference
Problem
You want to highlight the search term(s) in a list of search results.
Solution
Contain the search term with the mark element:
<p>Your search for <mark>awesomesauce</mark> resulted in 923 entries:</p>
Discussion
mark is an entirely new element in HTML5. While the most common scenario for its
use is likely for search terms, according to the spec it can be more broadly used for text
that is “marked or highlighted for reference purposes, due to its relevance in another
text.”
mark adds no additional semantic importance or emphasis to the text it contains, but
current browsers (that doesn't include IE before version 9) do display the content with
a yellow background by default (see Figure 1-4 ), which you can change with CSS.
Figure 1-4. Browsers render the <mark> element with a yellow background by default
See Also
HTML5 Doctor's article “Draw attention with mark” at http://html5doctor.com/draw
-attention-with-mark/ .
 
Search WWH ::




Custom Search