Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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=utf-8" />
<title>Hearts</title>
</head>
<body>
&#2665;
</body>
</html>
like image 767
siva636 Avatar asked Aug 23 '11 03:08

siva636


People also ask

How do I use Unicode characters in HTML?

You can enter any Unicode character in an HTML file by taking its decimal numeric character reference and adding an ampersand and a hash at the front and a semi-colon at the end, for example &#8212; should display as an em dash (—). This is the method used in the Unicode test pages.

Does HTML support Unicode?

The Unicode Standard has become a success and is implemented in HTML, XML, Java, JavaScript, E-mail, ASP, PHP, etc. The Unicode standard is also supported in many operating systems and all modern browsers.


2 Answers

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.

like image 117
icktoofay Avatar answered Nov 15 '22 17:11

icktoofay


Encoded entities:

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

Output:

♥ ♥ ♥ ♡ ❤ ❥

Note the x required.

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

like image 36
Stefan Kendall Avatar answered Nov 15 '22 17:11

Stefan Kendall