开发者

Why Unicode character for "Hearts" symbol fails with HTML

According to my understanding the following HTML markup should display a heart symbol, but it is not. What I am missing? I got the data about Unicode characters here: http://en.wikipedia.org/wiki/Html_special_characters#Character_entity_references_in_HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=u开发者_开发技巧tf-8" />
<title>Hearts</title>
</head>
<body>
&#2665;
</body>
</html>


The XML/HTML &#NNNN; notation is for decimal values. Try using the &#xNNNN; form to force it to interpret it as hexadecimal, or, alternatively, use the decimal value.


Encoded entities:

&hearts; &#x2665; &#9829;
&#x2661; &#x2764; &#x2765;

Output:

♥ ♥ ♥ ♡ ❤ ❥

Note the x required.

Without the x:
&#2661; &#2665;
੥ ੩


<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hearts</title>
</head>
<body>
&#x2665;

&hearts;
</body>

Works in FireFox/Chrome/IE. Looks like you forgot the "x" bit in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜