XHTML Transitional 1.o Highlight single word within unordered ul tag
I have an unordered list and each item is a sentence. I would like to highlight a word or two within the sentence but the font color tag
<font color="CC9966">highlighted开发者_StackOverflow words </font>
generates an error. Can anyone please suggest a fix for this? I have tried putting it in
<li> </li>
and while it works and generates no error, but this is not the formatting I want as I have a roll over on the li in my CSS style sheet. Thank you.
Wrap a span around the word you want to highlight. It would probably be easier to make a class in the CSS called highlight and use that though.
<span style="color:#DD0000">wordToHighlight</span>
You can check a documents validity by using the W3C Markup Validator. These are the people that make the rules. If you change the tab to validate by direct input and put in:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>test</title>
</head>
<body>
<ul>
<li>this is a <span style="color:#FF0000">test</span> sentence</li>
</ul>
</body>
</html>
You will see that a span in a li is valid markup.
精彩评论