TYPING GUIDE / WEB TEXT

HTML and Unicode for accented letters

Use UTF-8, literal Unicode characters, HTML character references, and normalization correctly when accented text moves through a website.

QUICK ANSWER

Declare UTF-8 and write the literal character whenever your files and response headers use UTF-8. An HTML named, decimal, or hexadecimal character reference can represent the same character in HTML source, but it is not required for ordinary accented text. Normalize text only when your application needs a consistent representation.

METHOD SELECTOR

Choose the fastest method for your task

The best method depends on how often you type the character, whether you know its name or code, and which input layout is active. Use this table as a starting point, then follow the detailed instructions below.

SituationBest starting methodWhy
Modern HTML documentLiteral UTF-8 characterReadable source and direct Unicode text
Character is awkward in sourceHTML character referenceRepresents the same character during HTML parsing
JavaScript stringLiteral character or Unicode escapeHTML entities are not decoded in ordinary JavaScript strings
Comparing or indexing textNFC normalizationReduces differences between common equivalent sequences

Use UTF-8 from file to response

Save HTML, CSS, JavaScript, and data files as UTF-8. Put the charset declaration near the start of an HTML document and configure the server to send the matching Content-Type charset. A mismatch between the declared and actual encoding can turn readable accents into replacement symbols or garbled sequences.

W3C internationalization guidance recommends UTF-8 for content. Copying é into a correctly configured UTF-8 document is normally preferable to hiding it behind a numeric reference.

  1. Save the source file as UTF-8.
  2. Include <meta charset="utf-8"> near the beginning of the document head.
  3. Send an HTTP Content-Type header with UTF-8 for text resources.
  4. Test the rendered page and the copied value, not only the source editor.

Choose literal characters or HTML references

The literal é, the named reference &eacute;, the decimal reference &#233;, and the hexadecimal reference &#xE9; resolve to the same precomposed character in HTML. Named references are case-sensitive and only exist for a defined set, while numeric references can address any valid Unicode code point.

Use references when they make source entry safer or when representing syntax-sensitive characters such as an ampersand. Do not paste the text &eacute; into a document, message, JSON value, or ordinary JavaScript string expecting every system to decode it.

Comparison of literal é, Unicode U+00E9, HTML named, decimal, and hexadecimal references with a UTF-8 declaration
Literal é and its HTML references resolve to the same precomposed character in HTML. Use UTF-8 consistently and use the syntax appropriate to the data context.Open full-size diagram
Important

Character references are HTML syntax. The clipboard and the visible document should usually contain the actual Unicode character.

Distinguish Unicode values from decimal HTML references

Unicode values are conventionally written in hexadecimal with U+, such as U+00E9 for é. An HTML decimal reference writes the decimal number 233, while a hexadecimal reference writes E9 after &#x. The digits look different because the numeral systems differ.

CSS and JavaScript have their own escape syntaxes. Confirm the syntax for the language and context instead of copying an HTML entity into every source file.

Handle composed and decomposed accents deliberately

The precomposed é can be stored as U+00E9. A canonically equivalent sequence can store U+0065 followed by U+0301. They often render alike, but byte-level comparison, search, validation, filenames, and string length can differ.

NFC generally composes common sequences, while NFD decomposes them. NFKC and NFKD also apply compatibility mappings and can change distinctions that matter to an application. Normalize at a defined boundary and preserve the original when exact archival fidelity is required.

TROUBLESHOOTING

When the method does not work

Text shows é instead of é

The bytes were decoded with the wrong encoding. Make the saved file, response header, and parser agree on UTF-8.

An HTML entity appears literally

The value is outside HTML parsing or the ampersand was escaped. Insert the Unicode character or use the correct syntax for that context.

Two identical-looking strings do not match

Inspect their code points and compare consistently normalized values, commonly NFC.

A font shows a missing box

The character can be valid even when the font lacks its glyph. Test a font with suitable script coverage.

COMMON QUESTIONS

Questions about html and unicode typing

Do accented letters need HTML entities?

No. Literal characters are appropriate when the document and server use UTF-8.

Is &#233; different from &eacute;?

Both resolve to precomposed é in HTML. One is decimal and the other is a named reference.

Should every string be normalized?

Normalize where consistent comparison or storage requires it. Compatibility normalization should be chosen carefully because it can erase distinctions.

Why can an accented letter use two code points?

Unicode supports combining marks, so a base letter and accent can be stored separately while remaining canonically equivalent to a precomposed form.

Other typing guides