<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb" -->

---
title: HTML Emoji Codes: Use Emojis in HTML, CSS, and JS
description: Emojis are plain characters, so you can paste them into HTML, CSS and JavaScript or write them by codepoint. Set UTF-8 encoding first. The hamburger (U+1F354)...
canonical: https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: HTML Emoji Codes: Use Emojis in HTML, CSS, and JS | daily.dev
og:description: Emojis are plain characters, so you can paste them into HTML, CSS and JavaScript or write them by codepoint. Set UTF-8 encoding first. The hamburger (U+1F354)...
og:url: https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb
og:image: https://api.daily.dev/og/posts/MOgkdhwhB.png
og:image:alt: HTML Emoji Codes: Use Emojis in HTML, CSS, and JS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# HTML Emoji Codes: Use Emojis in HTML, CSS, and JS

**[Kirupa](https://daily.dev/sources/kirupa)** · 19 min read · 0 upvotes · 0 comments

## Summary

Emojis are plain characters, so you can paste them into HTML, CSS and JavaScript or write them by codepoint. Set UTF-8 encoding first. The hamburger (U+1F354) is &#x1F354; in HTML, "\01F354" in CSS, and String.fromCodePoint(0x1F354) or "\u{1F354}" in JavaScript. Skin tones, flags and ZWJ emojis like 👩💻 are several codepoints, so "👩💻".length is 5 while Intl.Segmenter counts 1. Meaningful emojis get role="img" and an aria-label, and decorative ones get aria-hidden="true".

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.kirupa.com/html5/emoji.htm>

## Questions this post answers

### Why does "👩‍💻".length return 5 in JavaScript, and how do I count it as one character?

JavaScript's length counts UTF-16 code units, not what you see. The woman technologist emoji is three codepoints (woman, a zero width joiner, laptop), and the emoji codepoints each take two code units, giving 5. Intl.Segmenter with granularity "grapheme" splits text into visible characters and counts it as 1.

_Developers handling text edge cases like this keep up on JavaScript pitfalls through daily.dev._

### How do I write the hamburger emoji with its codepoint U+1F354 in HTML, CSS, and JavaScript?

In HTML, use the character reference &#x1F354;. In CSS, write content: "\01F354" by dropping the U+ and prefixing \0. In JavaScript, use String.fromCodePoint(0x1F354) or the escape "\u{1F354}". Set <meta charset="UTF-8"> in your head first so the emoji displays consistently across browsers and devices.

_If you keep forgetting syntax differences across HTML, CSS, and JS, daily.dev surfaces handy webdev references._

### How should I make emojis accessible to screen readers in HTML?

When an emoji carries meaning on its own, set role="img" and an aria-label on its element, for example <p role="img" aria-label="hamburger">🍔</p>. When it is purely decorative, such as a party popper beside text that already says "Congratulations!", hide it with aria-hidden="true" so screen readers skip it.

_Developers building accessible interfaces follow accessibility practices on daily.dev._

## Similar posts on daily.dev

- [why the trans flag emoji uses the codepoints it uses](https://daily.dev/posts/why-the-trans-flag-emoji-uses-the-codepoints-it-uses-gk0q5awvj) · Hacker News · 0 upvotes · 0 comments
- [Emoji Are Obsolete](https://daily.dev/posts/emoji-are-obsolete-nur6kkeds) · SQL Authority · 23 upvotes · 22 comments
- [The following is a valid DOS COM executable](https://daily.dev/posts/the-following-is-a-valid-dos-com-executable-9dmiwxytc) · Lobsters · 0 upvotes · 0 comments
- [The Goat Emoji Is 100% Valid Machine Code, And It Doesn’t Stop There](https://daily.dev/posts/the-goat-emoji-is-100-valid-machine-code-and-it-doesn-t-stop-there-yp0gnr5tg) · Hackaday · 0 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"HTML Emoji Codes: Use Emojis in HTML, CSS, and JS","url":"https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb"},"datePublished":"2026-11-28T06:30:38.497Z","dateModified":"2026-11-28T06:30:59.821Z","description":"Emojis are plain characters, so you can paste them into HTML, CSS and JavaScript or write them by codepoint. Set UTF-8 encoding first. The hamburger (U+1F354)...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/872b4729587a2eb0f772b08aac6d4cb9?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/872b4729587a2eb0f772b08aac6d4cb9?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Kirupa","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kirupa","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ff2fdb4927d34b81bd07cd18d6049a98","url":"https://daily.dev/sources/kirupa"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,css,html,accessibility","timeRequired":"PT19M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kirupa","item":"https://daily.dev/sources/kirupa"},{"@type":"ListItem","position":3,"name":"HTML Emoji Codes: Use Emojis in HTML, CSS, and JS"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/html-emoji-codes-use-emojis-in-html-css-and-js-mogkdhwhb#faq","mainEntity":[{"@type":"Question","name":"Why does \"👩‍💻\".length return 5 in JavaScript, and how do I count it as one character?","acceptedAnswer":{"@type":"Answer","text":"JavaScript's length counts UTF-16 code units, not what you see. The woman technologist emoji is three codepoints (woman, a zero width joiner, laptop), and the emoji codepoints each take two code units, giving 5. Intl.Segmenter with granularity \"grapheme\" splits text into visible characters and counts it as 1. Developers handling text edge cases like this keep up on JavaScript pitfalls through daily.dev."}},{"@type":"Question","name":"How do I write the hamburger emoji with its codepoint U+1F354 in HTML, CSS, and JavaScript?","acceptedAnswer":{"@type":"Answer","text":"In HTML, use the character reference \u0026#x1F354;. In CSS, write content: \"\\01F354\" by dropping the U+ and prefixing \\0. In JavaScript, use String.fromCodePoint(0x1F354) or the escape \"\\u{1F354}\". Set \u003cmeta charset=\"UTF-8\"\u003e in your head first so the emoji displays consistently across browsers and devices. If you keep forgetting syntax differences across HTML, CSS, and JS, daily.dev surfaces handy webdev references."}},{"@type":"Question","name":"How should I make emojis accessible to screen readers in HTML?","acceptedAnswer":{"@type":"Answer","text":"When an emoji carries meaning on its own, set role=\"img\" and an aria-label on its element, for example \u003cp role=\"img\" aria-label=\"hamburger\"\u003e🍔\u003c/p\u003e. When it is purely decorative, such as a party popper beside text that already says \"Congratulations!\", hide it with aria-hidden=\"true\" so screen readers skip it. Developers building accessible interfaces follow accessibility practices on daily.dev."}}]}
```

