On this page (8)
Heart symbol HTML code: the short list
You can put a heart on a web page in three ways: paste the character directly, use a named entity, or use a numeric character reference. Here are the codes for the hearts people ask about most:
| Heart | Named entity | Decimal | Hex |
|---|---|---|---|
| ♥ | ♥ or ♥ |
♥ |
♥ |
| ♡ | none | ♡ |
♡ |
| ❤ | none | ❤ |
❤ |
| ❤️ | none | ❤️ |
❤️ |
| ❣ | none | ❣ |
❣ |
| 💖 | none | 💖 |
💖 |
The reference table above lists the code point, HTML code, CSS escape and JavaScript escape for every heart on this site. If you need the theory behind these numbers, the heart Unicode guide explains code points and variation selectors.
Using heart entities in HTML
Entities and numeric references are interpreted by the browser, so they work even if your editor can’t type the heart. Paste this into any page:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hearts</title>
</head>
<body>
<p>I ♥ HTML</p> <!-- ♥ -->
<p>Outline: ♡</p> <!-- ♡ -->
<p>Emoji: ❤️</p> <!-- ❤️ -->
<p>Sparkles: 💖</p> <!-- 💖 -->
</body>
</html>
Entity or literal character? In a UTF-8 page, typing ♥ directly is perfectly valid and easier to read. Entities are handy when your tools mangle special characters, or when you want the code to be obvious in the source.
Always declare UTF-8. The meta charset line should be the first thing inside head. Without it, some browsers may guess a legacy encoding and show ♥ instead of ♥, because the three UTF-8 bytes of the heart get read as three separate Western characters.
Red heart HTML code
There are two ways to show a red heart, and they behave differently:
| Approach | Code | Color control |
|---|---|---|
| Text heart, colored with CSS | ♥ plus color: #e11d48 |
Full: any color you like |
| Emoji heart | ❤️ |
None: the emoji is always red |
Text hearts like ♥ and ♡ behave like letters, so color, font-size and text-shadow all apply. Emoji such as ❤️ and the red heart emoji are drawn by the operating system’s emoji font, so they keep their own colors. If you need a heart that matches your brand color, use the text heart.
For a scalable heart icon you can style freely, an inline SVG is another option. See heart SVG for ready-made code.
Pick the right heart for your design
On a web page, ♥, ❤ and ❤️ can look surprisingly different:
- ♥ (
U+2665) is drawn by your page’s font, if the font has it, or by a fallback font. It takes your text color. - ❤ (
U+2764) on its own may appear as a black text heart or a red emoji, depending on the browser and operating system. - ❤️ (
U+2764 U+FE0F) asks for emoji style, so it’s red on almost every device.
If the look matters, be explicit. Add ︎ after the heart for text style or ️ for emoji style. The heart suit guide explains why one character can have two looks.
To make emoji consistent across systems, many sites list the common emoji fonts at the end of their font stack, for example "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji". Each device uses whichever one it has.
CSS content heart
CSS escapes are a backslash followed by the hex code point. They’re commonly used in the content property of ::before and ::after:
.love::before {
content: "\2665"; /* ♥ */
color: #e11d48;
margin-right: 0.25em;
}
.outline::after { content: "\2661"; } /* ♡ */
.sparkle::before { content: "\1F496"; } /* 💖 */
.text-only::before { content: "\2665\FE0E"; } /* ♥︎ text style */
Watch out for one gotcha: CSS swallows a single space after an escape, because the space is treated as the end of the hex code.
.a::before { content: "\2665 Love"; } /* shows ♥Love */
.b::before { content: "\2665" " Love"; } /* shows ♥ Love */
To use hearts as list bullets in every browser, hide the default marker and add a pseudo-element:
ul.hearts { list-style: none; padding-left: 1.4em; }
ul.hearts li::before {
content: "\2665";
color: #e11d48;
display: inline-block;
width: 1.4em;
margin-left: -1.4em;
}
JavaScript heart unicode
JavaScript strings are UTF-16, which affects how hearts above U+FFFF behave:
const heart = "\u2665"; // ♥
const outline = "\u2661"; // ♡
const red = "\u2764\uFE0F"; // ❤️
const sparkle = "\u{1F496}"; // 💖 (ES2015+)
const legacy = "\uD83D\uDC96"; // 💖 as a surrogate pair
String.fromCodePoint(0x1F496); // "💖"
"♥".codePointAt(0).toString(16); // "2665"
"💖".length; // 2 (UTF-16 code units)
[..."💖"].length; // 1 (code points)
"❤️".length; // 2 (heart + variation selector)
The .length surprise matters for character limits and truncation. Splitting a string in the middle of a surrogate pair or a ZWJ sequence like ❤️🔥 leaves a broken character. To count what people actually see, use Intl.Segmenter, which is supported in modern browsers:
const seg = new Intl.Segmenter("en", { granularity: "grapheme" });
[...seg.segment("❤️🔥💖")].length; // 2
Hearts in JSON and JSX
JSON uses the same escape style as JavaScript, so a heart can be stored either as the literal character or as an escape, and both parse to the same string. In React’s JSX, you can write the heart directly in text, use an HTML entity like ♥ in JSX text, or put a JavaScript string inside braces. Entities don’t work inside JavaScript strings, only in JSX text.
URL encoding hearts
URLs can only contain a limited set of ASCII characters, so hearts are percent-encoded as their UTF-8 bytes:
| Heart | URL encoded |
|---|---|
| ♥ | %E2%99%A5 |
| ♡ | %E2%99%A1 |
| ❤️ | %E2%9D%A4%EF%B8%8F |
In JavaScript, encodeURIComponent does this for you:
encodeURIComponent("I ♥ you"); // "I%20%E2%99%A5%20you"
decodeURIComponent("%E2%99%A5"); // "♥"
Accessibility tips
Screen readers announce hearts by name, often something like “black heart suit.” If a heart is purely decorative, hide it with aria-hidden="true". If it carries meaning, give it a clear label instead:
<span aria-hidden="true">♥</span> Favorites
<span role="img" aria-label="love">❤️</span>
Writing documents rather than web pages? See the heart symbol LaTeX guide, or how to type a heart symbol on any keyboard. For the ♥ vs ❤ difference, see the heart suit guide.