Heart Symbol HTML, CSS & JavaScript Codes

The heart symbol HTML code is ♥ (or ♥ or ♥), which displays ♥. The outline heart ♡ has no named entity, so use ♡. For the red heart emoji ❤️, write ❤️. In CSS, put the escape \2665 inside content; in JavaScript, use the string "\u2665".

Updated

Tap a heart to copy it

8 hearts

Tap to copy · long-press or right-click for more

Heart HTML, CSS & JavaScript codes

47 hearts · tap a code to copy
HeartNameCode pointHTMLCSSJavaScript
Black Heart Suit
White Heart Suit
Red Heart
Rotated Heavy Black Heart Bullet
Heart Exclamation
Floral Heart
Rotated Floral Heart Bullet
Reversed Rotated Floral Heart Bullet
Heart with Tip on the Left
Georgian Letter Ghan (ღ)
Aesthetic Heart ᥫ᭡
Medefaidrin Heart 𖹭
Cham Heart ꨄ
Hieroglyph Heart 𓆩♡𓆪
Pink Heart
Orange Heart
Yellow Heart
Green Heart
Blue Heart
Light Blue Heart
Purple Heart
Brown Heart
Black Heart
Grey Heart
White Heart
Broken Heart
Heart on Fire
Mending Heart
Two Hearts
Revolving Hearts
Beating Heart
Growing Heart
Sparkling Heart
Heart with Arrow
Heart with Ribbon
Heart Decoration
Love Letter
Anatomical Heart
Heart Hands
Hand with Index Finger and Thumb Crossed
Smiling Face with Hearts
Smiling Face with Heart-Eyes
Face Blowing a Kiss
Smiling Cat with Heart-Eyes
Couple with Heart
Kiss
Love-You Gesture
On this page (8)
  1. Heart symbol HTML code: the short list
  2. Using heart entities in HTML
  3. Red heart HTML code
  4. Pick the right heart for your design
  5. CSS content heart
  6. JavaScript heart unicode
  7. URL encoding hearts
  8. Accessibility tips

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 &hearts; HTML</p>              <!-- ♥ -->
  <p>Outline: &#9825;</p>              <!-- ♡ -->
  <p>Emoji: &#x2764;&#xFE0F;</p>       <!-- ❤️ -->
  <p>Sparkles: &#x1F496;</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 &hearts; plus color: #e11d48 Full: any color you like
Emoji heart &#x2764;&#xFE0F; 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 &#xFE0E; after the heart for text style or &#xFE0F; 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 &hearts; 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">&hearts;</span> Favorites
<span role="img" aria-label="love">&#x2764;&#xFE0F;</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.

Frequently asked questions

What is the HTML entity for a heart?

The named entity is &hearts;, which displays ♥ (U+2665). HTML5 also accepts &heartsuit; for the same character. Numeric references work everywhere too: &#9829; in decimal or &#x2665; in hex. There's no named entity for the outline heart ♡, so use &#9825; or &#x2661;.

What is the red heart HTML code?

For the red heart emoji ❤️, use &#x2764;&#xFE0F; (or &#10084;&#65039; in decimal). The second code is the emoji variation selector, which asks for the colorful emoji style. Alternatively, use &hearts; and color it red with CSS. Text hearts take any color, while emoji keep their own.

How do I add a heart with CSS?

Use a pseudo-element with an escaped code point: .love::before { content: "\2665"; }. Escapes in CSS are a backslash followed by the hex code, so ♡ is \2661 and 💖 is \1F496. You can also type the heart directly in a stylesheet saved as UTF-8.

How do I write a heart in JavaScript?

Use "\u2665" for ♥ or "\u2661" for ♡. For emoji above U+FFFF, use the ES2015 form "\u{1F496}" or String.fromCodePoint(0x1F496). Older code writes the same emoji as a surrogate pair, "\uD83D\uDC96". Typing the heart directly into a UTF-8 source file also works.

Why does my heart show as ♥ on my website?

That's a sign your page's UTF-8 bytes are being read with the wrong encoding. Add <meta charset="utf-8"> as the first element inside <head>, make sure your server sends a UTF-8 charset header, and save your files as UTF-8. Using &hearts; or &#9829; also sidesteps the problem.

Related pages

Your text — tap hearts to add0