Meta Charset Tag
What <meta charset="utf-8"> melakukan, why HTML spec ingin ini di pertama 1024 bytes, how sebuah wrong encoding causes mojibake, dan why ini adalah sebuah rendering-correctness issue alih-alih sebuah peringkat factor.
Bahasa
1 sinyal bukti di halaman ini
- Alat aktif terkaitHTTP Header Checker
meta charset tag — <meta charset="utf-8"> — declares Anda halaman's character encoding so browser dan crawler turn raw bytes ke right characters. HTML spec memerlukan ini di dalam pertama 1024 bytes dari document, dan best practice adalah literal pertama child dari <head>. Get ini wrong (missing, late, atau sebuah mismatched encoding) dan Anda get mojibake: accented letters, curly quotes, em dashes, non-Latin scripts, dan emoji render sebagai garbage — which dapat corrupt what's displayed dan terindeks. ini adalah NOT sebuah direct peringkat factor; Google's hanya guidance adalah untuk 'gunakan Unicode/UTF-8 where mungkin.' UTF-8 adalah near-universal, spec-diperlukan encoding untuk HTML5 today. sebuah server-dikirim konten-jenis header charset overrides di-halaman tag, which adalah sebuah umum source dari migration bugs. ini adalah one dari browser-facing tags di meta-tags cluster.
TL;DR — meta charset tag adalah one line dari HTML —
Evidence for this claim For HTML documents, the charset declaration must identify UTF-8. Scope: Modern HTML conformance requirements. Confidence: high · Verified: WHATWG HTML: Character encoding declaration Evidence for this claim The complete character-encoding declaration must occur within the first 1024 bytes of the document. Scope: HTML serialization requirement intended to make encoding available early to parsers. Confidence: high · Verified: WHATWG HTML: Specifying the document's character encoding<meta charset="utf-8">— itu tells browser cara read Anda halaman’s text. Get ini wrong atau leave ini out dan special characters (accents, curly quotes, emoji) dapat turn ke garbled nonsense. ini doesn’t help Anda peringkat, tetapi broken-looking text adalah buruk untuk everyone, including Google. Put ini pertama di Anda<head>dan gunakanutf-8. Done.
What tag melakukan
setiap halaman web adalah stored sebagai raw bytes. itu bytes hanya become letters Anda read once something decides which character setiap byte (atau group dari bytes) mewakili. meta charset tag adalah how Anda halaman tells browser — dan mesin pencari crawler — which sistem untuk gunakan:
<meta charset="utf-8">utf-8 adalah encoding Anda ingin di almost setiap case. ini dapat mewakili essentially
setiap character dan script di gunakan today, plus emoji, semua di one sistem.
What goes wrong without ini
jika Anda tidak declare sebuah encoding, browser memiliki untuk guess. When ini guesses wrong,
Anda get mojibake — garbled text where sebuah curly apostrophe becomes something like
’, atau café menampilkan up sebagai café. Accented letters, em dashes, “smart” (terjemahan) “smart” quotes,
non-Latin scripts (Arabic, Cyrillic, Chinese, Japanese), dan emoji adalah usual
casualties. Plain unaccented English dapat look fine bahkan when encoding adalah wrong,
which adalah exactly why bug sneaks melalui.
Where untuk put ini
Two sederhana aturan:
- Put
<meta charset="utf-8">pertama inside Anda<head>, sebelum judul atau anything else. - gunakan
utf-8, not beberapa older encoding.
itu’s ini. sebagian besar situs templates dan CMSs sudah melakukan ini untuk Anda — jika yours doesn’t, tambahkan ini.
melakukan ini affect SEO?
Not directly. charset tag adalah not sebuah peringkat factor. tetapi jika sebuah wrong encoding garbles Anda text, itu broken konten adalah what pengguna see dan what Google dapat end up pengindeksan dan showing — so ini adalah worth getting right bahkan though ini won’t move Anda up hasil oleh itself.
ingin spec detail — “first 1024 bytes” (terjemahan) “pertama 1024 bytes” aturan, why old syntax masih hangs sekitar, dan how sebuah server header dapat quietly override Anda tag? Switch untuk Advanced tab.
periksa declared encoding dari command line
Replace URL, lalu compare respons header dengan tag near start dari
HTML. sebuah charset di HTTP Content-Type header takes precedence di atas
di-document declaration.
url="https://example.com/"
curl -sSI "$url" | grep -i '^content-type:'
curl -sS "$url" | head -c 1024 | grep -oiE '<meta[^>]+charset[^>]*>'di sebuah browser console, ini reports parsed encoding, declared tag, dan
whether itu tag adalah pertama element di <head>:
const charset = document.querySelector('meta[charset]');
console.table({
documentCharacterSet: document.characterSet,
declaredCharset: charset?.getAttribute('charset') ?? 'missing',
firstHeadElement: document.head.firstElementChild?.outerHTML ?? 'missing',
charsetIsFirst: document.head.firstElementChild === charset,
});console reflects browser’s parsed document. gunakan curl periksa sebagai well
when Anda perlu prove what server actually dikirim.
Inspect respons sebelum debugging markup
gunakan header HTTP Checker untuk inspect live
Content-Type respons header. jika ini declares sebuah charset, compare itu nilai dengan
<meta charset="utf-8">; sebuah conflict dapat jelaskan mojibake bahkan when HTML tag
looks correct.
untuk placement, gunakan View Source alih-alih hanya Elements panel. Confirm
charset declaration adalah pertama child dari <head> dan appears di dalam pertama
1 024 bytes dari document.
Validate sebuah charset fix
Test 1 — Header dan tag agree
- Hypothesis: live respons dan HTML both declare UTF-8.
- metode: periksa respons
Content-Typeheader, lalu inspect View Source untuk<meta charset="utf-8">. - Pass condition: No conflicting server-declared charset exists.
- Fail condition: header declares lainnya encoding atau tag adalah missing.
- Next tindakan: Fix server header pertama, lalu retest live respons.
Test 2 — declaration adalah early enough
- Hypothesis: browser sees tag sebelum ini memiliki untuk guess sebuah encoding.
- metode: Fetch pertama 1 024 bytes dan inspect start dari
<head>. - Pass condition: complete charset tag adalah di dalam itu bytes dan adalah
pertama element di
<head>. - Fail condition: Comments, injected scripts, atau lainnya markup push ini later.
- Next tindakan: Move tag ahead dari semua nonessential head markup.
Test 3 — nyata characters render correctly
- Hypothesis: fix eliminates mojibake di pengguna-terlihat dan dapat diindeks text.
- metode: Spot-periksa sebuah accented character, curly quote, em dash, non-Latin text, dan emoji pada live halaman dan di View Source.
- Pass condition: setiap character renders sebagai authored setelah sebuah hard refresh.
- Fail condition: Replacement glyphs atau garbled byte sequences remain.
- Next tindakan: Roll back encoding perubahan jika ini introduced corruption, lalu trace source file, template, database, dan respons header separately.
TL;DR —
Evidence for this claim For HTML documents, the charset declaration must identify UTF-8. Scope: Modern HTML conformance requirements. Confidence: high · Verified: WHATWG HTML: Character encoding declaration Evidence for this claim The complete character-encoding declaration must occur within the first 1024 bytes of the document. Scope: HTML serialization requirement intended to make encoding available early to parsers. Confidence: high · Verified: WHATWG HTML: Specifying the document's character encoding<meta charset="utf-8">declares document’s character encoding. WHATWG HTML spec memerlukan declaration untuk menjadi serialized completely di dalam pertama 1024 bytes dari document, dan untuk HTML5 nilai harus matchutf-8; best practice adalah placing ini sebagai literal pertama child dari<head>. sebuah missing, late, atau mismatched encoding produces mojibake — corrupted accented characters, curly quotes, non-Latin scripts, dan emoji — which adalah sebuah rendering dan pengindeksan-correctness masalah, not sebuah sinyal peringkat. Google’s hanya public line adalah “use Unicode/UTF-8 where possible.” (terjemahan) “gunakan Unicode/UTF-8 where mungkin.” sebuah server-dikirimContent-Typecharset header overrides di-document tag, which adalah sebuah classic post-migration mojibake bug. hanya one charset meta element adalah allowed per document, dan ini memiliki no effect di XML. sebuah UTF-8 byte-order mark (BOM), jika present, wins di atas everything else; otherwise header HTTP wins di atas di-halaman tag — full precedence order below.
What tag adalah
charset declaration tells sebuah parser which character encoding untuk gunakan when ini turns
document’s bytes ke text. WHATWG HTML Living Standard puts ini plainly: “The
charset attribute specifies the character encoding used by the document. This is a
character encoding declaration.” (terjemahan) “
undefined attribute specifies character encoding digunakan oleh document. ini adalah sebuah
character encoding declaration.” MDN’s framing adalah practical versi: “This
attribute declares the document’s character encoding.” (terjemahan) “ini
attribute declares document’s character encoding.”
modern syntax adalah pendek form:
<meta charset="utf-8">There’s juga sebuah legacy pre-HTML5 form Anda’ll masih see di older templates:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">Both declare yang sama thing. pada sebuah modern HTML5 document Anda hanya perlu pendek
<meta charset="utf-8"> — menggunakan both adalah redundant, not harmful, dan spec allows
hanya one charset-declaring meta element per document anyway. ( http-equiv form adalah
best thought dari sebagai legacy alih-alih something untuk tambahkan fresh; jika Anda’re auditing sebuah halaman
itu memiliki ini, ini isn’t broken, ini adalah hanya old.)
spec requirements Anda actually perlu untuk know
UTF-8 adalah effectively mandatory untuk HTML5. MDN states ini directly: attribute’s
“value must be an ASCII case-insensitive match for the string utf-8, because UTF-8
is the only valid encoding for HTML5 documents.” (terjemahan) “nilai harus menjadi sebuah ASCII case-insensitive match untuk string undefined, because UTF-8
adalah satu-satunya valid encoding untuk HTML5 documents.” WHATWG spec goes further dan
memerlukan document’s actual encoding untuk menjadi UTF-8 regardless dari what’s declared.
UTF-8 covers essentially setiap script plus emoji, which adalah why ISO-8859-1 /
Windows-1252 / Shift-JIS era dari per-region encodings adalah di atas untuk baru berfungsi — itu
survive hanya sebagai legacy compatibility cases.
ini harus land di pertama 1024 bytes dari document. ini adalah sebuah hard spec
requirement, not sebuah soft suggestion. MDN: “<meta> elements which declare a character
encoding must be located entirely within the first 1024 bytes of the document.” (terjemahan) “undefined elements which declare sebuah character
encoding harus menjadi located entirely di dalam pertama 1024 bytes dari document.”
alasan adalah mechanical — parser sniffs byte stream untuk sebuah encoding sebelum ini
dapat safely interpret rest. jika Anda declaration menampilkan up too late, parser dapat
sudah memiliki committed untuk sebuah guessed encoding (atau memiliki untuk restart, which costs
performa). Note framing carefully: ini adalah pertama 1024 bytes dari entire
document, not hanya dari <head>.
Best practice beats spec minimum: membuat ini pertama child dari <head>. Don’t
settle untuk “somewhere in the first 1024 bytes” (terjemahan) “somewhere di pertama 1024 bytes” — put <meta charset="utf-8"> sebelum
Anda <title>, <link>, <script>, <style>, dan setiap lainnya tag. ini adalah
placement modern tooling memeriksa. There’s sebuah open
Lighthouse issue (#10023)
proposing sebuah audit itu specifically memeriksa whether <meta charset> equals
document.head.firstElementChild — i.e. flagging tag when ini isn’t literal
pertama element di head, not merely when ini adalah missing. direction dari tooling adalah toward
memeriksa placement, not hanya presence.
hanya one charset meta element per document, dan ** charset attribute memiliki no
effect di XML/XHTML documents** (ini adalah permitted there hanya untuk ease migration untuk dan
dari XML). Worth sebuah caveat jika Anda’re berfungsi dengan XHTML-disajikan konten atau
RSS/Atom-adjacent templates.
BOM, header HTTP, meta tag — precedence order
browser don’t hanya read meta tag di isolation; encoding-sniffing algorithm memeriksa three sources di sebuah fixed order, dan pertama one itu gives sebuah jawaban wins:
- sebuah UTF-8 byte-order mark (BOM) — sebuah few bytes di very start dari file. jika browser detects sebuah BOM, itu determines encoding dengan certainty; nothing else adalah consulted.
- ** HTTP
Content-Typeheader’s charset**, jika server mengirim one dan there’s no BOM. ini takes precedence di atas di-document meta declaration. - ** di-document
<meta charset>(atau legacyhttp-equiv) declaration**, diperiksa hanya jika neither dari above supplied sebuah encoding.
dalam praktik, BOMs adalah rare pada hand-authored HTML (mereka’re more umum sebagai sebuah artifact
dari certain text editors atau file-export alat), so header-vs-tag conflict adalah
one itu bites sebagian besar sering: sebuah halaman itu correctly declares <meta charset="utf-8">
dapat masih render garbled jika sebuah CDN, reverse proxy, atau misconfigured server mengirim sebuah
berbeda charset di header. ini adalah sebuah classic symptom right setelah sebuah server atau CDN
migration — HTML didn’t perubahan, tetapi header melakukan, dan now header adalah
fighting tag. When Anda’re debugging mojibake, periksa untuk sebuah BOM dan respons
header charset, not hanya halaman source.
adalah meta charset sebuah SEO peringkat factor?
No — dan ini adalah worth menjadi blunt because fear-based audit-alat copy sometimes implies otherwise. ini adalah sebuah rendering- dan pengindeksan-correctness prerequisite, not sebuah peringkat signal.
Google’s guidance here adalah thin dan indirect dibandingkan dengan tags ini discusses constantly (judul, deskripsi meta, robots, canonical). tidak ada dedicated Google Search Central halaman tentang character encoding — ini adalah one entry inside umum meta tags Google mendukung reference, di bawah “Content-Type and charset.” (terjemahan) “konten-jenis dan charset.” Google’s hanya pada-record line adalah sebuah recommendation, not sebuah peringkat claim: “We recommend using Unicode/UTF-8 where possible.” (terjemahan) “kami recommend menggunakan Unicode/UTF-8 where mungkin.” No verbatim statement dari Mueller, Illyes, Splitt, atau Canel specifically naming “meta charset” (terjemahan) “meta charset” atau “mojibake” (terjemahan) “mojibake” surfaces di trade press atau Search Off Record archives — charset adalah treated sebagai basic web-standards hygiene, table stakes like valid markup, alih-alih sebuah topic warranting SEO commentary.
Bing memiliki no distinct public position pada pada-halaman tag either; -nya documentation
references UTF-8 hanya untuk -nya own API/feed formats (IndexNow key files, Webmaster API
permintaan headers), not sebagai guidance tentang HTML <meta charset> pada Anda halaman. Since
Bingbot adalah sebuah standard HTML parser, practical implication adalah yang sama: ikuti
HTML spec’s UTF-8 / 1024-byte aturan.
So where dapat ini hurt Anda? Indirectly, dan hanya when encoding adalah genuinely broken: garbled text adalah sebuah konten-quality dan UX masalah, ini dapat corrupt what appears di snippets, dan severely broken output dapat look broken untuk Google’s pengindeksan sistem too. industry consensus, sebagai Ahrefs’ own meta-tags guide (oleh Joshua Hardwick) puts ini, adalah itu “unless your page is severely broken as a result of charset issues (which is unlikely), the impact is going to be quite minimal.” (terjemahan) “unless Anda halaman adalah severely broken akibatnya dari charset issues (which adalah unlikely), impact adalah going untuk menjadi quite minimal.” Fix ini because broken text adalah buruk, not because Anda expect sebuah peringkat bump.
cara periksa dan fix ini
sebuah quick diagnostic path when Anda suspect sebuah encoding masalah:
- View source / DevTools. Confirm
<meta charset="utf-8">exists dan adalah pertama child dari<head>. di DevTools, periksaContent-Typerespons header untuk sebuah charset nilai — jika ini disagrees dengan tag, header wins dan adalah Anda mungkin culprit. aturan out sebuah BOM too: ini adalah rarer, tetapi jika present ini beats both header dan tag. - Validators dan crawler flag ini. W3C validator dan aturan-based checkers (e.g. Rocket Validator’s “charset after the first 1024 bytes” (terjemahan) “charset setelah pertama 1024 bytes” aturan) akan panggil out sebuah late atau missing declaration. situs audits di Ahrefs situs Audit dan Screaming Frog surface charset issues di seluruh sebuah whole situs.
- Fix right layer. jika placement adalah wrong, move tag untuk top dari head.
jika encoding adalah wrong ( bytes themselves aren’t UTF-8, atau header mengirim sebuah
conflicting charset), fixing meta tag alone won’t help — Anda memiliki untuk re-encode
file sebagai UTF-8 dan/atau correct server’s
Content-Typeheader so header dan tag agree.
fix adalah almost selalu trivial setelah Anda’ve identified which layer adalah di fault. ini adalah sebuah stable, panjang-settled bagian dari HTML spec — there’s no recent deprecation atau platform-perilaku perubahan untuk track; satu-satunya evolving nuance adalah tooling increasingly memeriksa placement, not hanya presence.
Where ini sits
charset tag adalah one dari browser-facing head elements — like viewport tag, ini adalah tentang rendering, not peringkat, which puts ini di sebuah berbeda bucket dari SEO-active tags di meta-tags cluster ( judul element, deskripsi meta, dan robots family). ini adalah adjacent untuk internationalization berfungsi I spend sebuah lot dari time pada: encoding adalah layer underneath hreflang dan multi-script konten — hreflang tells Google which language/region versi untuk sajikan, tetapi jika encoding adalah wrong text di itu versi adalah garbled regardless. untuk full map dari head elements grouped oleh job mereka melakukan, see meta tags hub.
AI summary
sebuah condensed take pada Advanced versi:
- What ini adalah:
<meta charset="utf-8">declares document’s character encoding so browser dan crawler map raw bytes untuk correct characters. - Spec aturan: declaration harus sit di dalam pertama 1024 bytes dari whole
document; HTML5 memerlukan nilai untuk menjadi
utf-8(dan actual encoding untuk menjadi UTF-8). Best practice: literal pertama child dari<head>. hanya one charset meta element per document; ini memiliki no effect di XML/XHTML. - Legacy syntax:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">adalah older pre-HTML5 form — redundant pada modern halaman; gunakan pendek form. Anda tidak perlu both. - Precedence order: sebuah UTF-8 BOM, jika present, wins di atas everything; otherwise sebuah
server-dikirim
Content-Typecharset overrides di-halaman tag — sebuah classic post-migration mojibake bug. Debug header (dan periksa untuk sebuah BOM), not hanya source. - mengapa ini penting: sebuah missing/late/mismatched encoding causes mojibake (garbled accents, curly quotes, non-Latin scripts, emoji) — sebuah rendering/pengindeksan-correctness issue, not sebuah peringkat factor.
- What Google says: hanya sebuah indirect line — “We recommend using Unicode/UTF-8 where possible.” (terjemahan) “kami recommend menggunakan Unicode/UTF-8 where mungkin.” No dedicated doc, no rep quote pada charset/mojibake. Bing memiliki no distinct pada-halaman position. Industry framing (Ahrefs): impact adalah minimal unless halaman adalah “severely broken.” (terjemahan) “severely broken.”
- Diagnose: view-source/DevTools untuk tag dan respons-header charset; validators (W3C, Rocket Validator) dan situs audits (Ahrefs, Screaming Frog) flag late atau missing declarations. Fix right layer — placement vs. actual encoding/header.
Official documentation
Primary-source dan spec documentation.
Standards (WHATWG / MDN)
- HTML Standard (WHATWG) — Specifying document’s character encoding — normative aturan: charset declaration, pertama-1024-bytes requirement, UTF-8, one-per-document limit, dan XML exception.
- HTML Standard (WHATWG) — Determining character encoding — encoding-sniffing algorithm: BOM detection pertama, lalu HTTP-tingkat
Content-Typecharset, lalu di-document meta declaration. - MDN —
<meta>: metadata element — plain-language reference:utf-8-hanya untuk HTML5, 1024-byte aturan, dan legacyhttp-equivform.
- Meta tags dan HTML attributes itu Google mendukung — satu-satunya Google guidance touching charset, di bawah “Content-Type and charset” (terjemahan) “konten-jenis dan charset”: accepted
http-equivdancharsetforms dan “use Unicode/UTF-8 where possible” (terjemahan) “gunakan Unicode/UTF-8 where mungkin” recommendation.
Bing / Microsoft
- IndexNow — getting started — Bing references UTF-8 hanya untuk -nya own API/key-file formats, not sebagai pada-halaman HTML guidance. tidak ada dedicated Bing doc pada
<meta charset>tag.
Tooling
- Lighthouse issue #10023 — warn tentang late atau missing
<meta charset>— proposed audit memeriksa whether charset tag adalahdocument.head.firstElementChild.
Quotes dari source
pada—record statements dari HTML spec, MDN, dan Google. setiap tautan adalah sebuah deep tautan itu jumps untuk quoted passage where source mendukung ini.
WHATWG HTML Standard — what tag adalah
- “The
charsetattribute specifies the character encoding used by the document. This is a character encoding declaration.” (terjemahan) “ undefined attribute specifies character encoding digunakan oleh document. ini adalah sebuah character encoding declaration.” — HTML Living Standard (WHATWG). Source
MDN — encoding dan placement aturan
- “This attribute declares the document’s character encoding. If the attribute is present, its value must be an ASCII case-insensitive match for the string
utf-8, because UTF-8 is the only valid encoding for HTML5 documents.<meta>elements which declare a character encoding must be located entirely within the first 1024 bytes of the document.” (terjemahan) “ini attribute declares document’s character encoding. jika attribute adalah present, -nya nilai harus menjadi sebuah ASCII case-insensitive match untuk string undefined, because UTF-8 adalah satu-satunya valid encoding untuk HTML5 documents. undefined elements which declare sebuah character encoding harus menjadi located entirely di dalam pertama 1024 bytes dari document.” — MDN Web Docs, “<meta>: the metadata element.” (terjemahan) “undefined: metadata element.” Jump untuk quote
Google — (thin) official position
- “These tags define the page’s content type and character set respectively. Make sure that you surround the value of the
contentattribute in thehttp-equivmetatag with quotes—otherwise thecharsetattribute may be interpreted incorrectly. We recommend using Unicode/UTF-8 where possible.” (terjemahan) “ini tags define halaman’s konten jenis dan character set respectively. pastikan itu Anda surround nilai dari undefined attribute di undefined undefined tag dengan quotes—otherwise undefined attribute dapat menjadi interpreted incorrectly. kami recommend menggunakan Unicode/UTF-8 where mungkin.” — Google Search Central, “Meta tags and attributes that Google supports.” (terjemahan) “Meta tags dan attributes itu Google mendukung.” Jump untuk quote
Industry — honest framing dari SEO impact
- “Unless your page is severely broken as a result of charset issues (which is unlikely), the impact is going to be quite minimal.” (terjemahan) “Unless Anda halaman adalah severely broken akibatnya dari charset issues (which adalah unlikely), impact adalah going untuk menjadi quite minimal.” — Ahrefs Blog, “Meta Tags for SEO: A Simple Guide for Beginners” (terjemahan) “Meta Tags untuk SEO: sebuah sederhana Guide untuk Beginners” (Joshua Hardwick). Source
Meta charset audit — checklist
sebuah quick pass untuk confirm Anda halaman declare dan render encoding correctly:
- setiap halaman memiliki
<meta charset="utf-8">di<head>. - charset tag adalah pertama child dari
<head>— sebelum<title>,<link>,<script>,<style>, dan apa pun lainnya<meta>. - declaration lands di dalam pertama 1024 bytes dari document (ini akan jika ini adalah pertama child dari head).
- nilai adalah
utf-8— not ISO-8859-1, Windows-1252, atau sebuah per-region code halaman. - file itself adalah actually saved/disajikan sebagai UTF-8 ( declaration dan nyata byte encoding harus agree).
- hanya one charset meta element per halaman.
- server’s
Content-Typerespons header charset agrees dengan tag ( header wins di atas tag jika mereka conflict) — verify di DevTools, terutama setelah apa pun CDN atau server migration. - No stray UTF-8 byte-order mark (BOM) di start dari file — rare, tetapi jika present ini outranks both header dan tag.
- Spot-periksa halaman dengan non-ASCII konten (accents, curly quotes, non-Latin scripts, emoji) — plain English dapat look fine bahkan when encoding adalah broken.
- Ran halaman melalui W3C validator / sebuah crawler (Ahrefs situs Audit, Screaming Frog) untuk catch late atau missing declarations di scale.
- Don’t tambahkan legacy
http-equiv="Content-Type"form fresh — pendek<meta charset="utf-8">adalah enough.
Meta charset cheat sheet
** two syntaxes**
| Form | Syntax | gunakan ini? |
|---|---|---|
| Modern (HTML5) | <meta charset="utf-8"> | Yes — ini adalah what Anda ingin |
| Legacy (pre-HTML5) | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | Not untuk baru berfungsi; redundant, hanya one needed |
** aturan itu penting**
| aturan | detail |
|---|---|
| nilai | harus menjadi utf-8 untuk HTML5 (spec memerlukan actual encoding untuk menjadi UTF-8 too) |
| Placement (spec minimum) | di dalam pertama 1024 bytes dari document |
| Placement (best practice) | literal pertama child dari <head> |
| Count | One charset meta element per document — no more |
| XML/XHTML | charset attribute memiliki no effect di XML documents |
| Precedence | sebuah UTF-8 BOM wins di atas everything; else sebuah server Content-Type header charset overrides di-halaman tag |
Fast facts
- Wrong/missing/late encoding → mojibake (garbled accents, curly quotes, non-Latin scripts, emoji). Plain ASCII English dapat masih look fine — bug hides.
- Not sebuah peringkat factor. Google’s hanya line: “use Unicode/UTF-8 where possible.” (terjemahan) “gunakan Unicode/UTF-8 where mungkin.”
- Impact adalah minimal unless halaman adalah severely broken (Ahrefs) — tetapi broken text adalah masih worth fixing untuk pengguna dan pengindeksan.
- Debugging mojibake? periksa untuk sebuah BOM pertama, lalu respons-header charset, not hanya view-source — BOM beats header, dan header beats tag.
- Tooling adalah moving toward memeriksa placement (pertama child dari head), not hanya presence (see Lighthouse #10023).
Test yourself: Meta Charset Tag
Five quick pertanyaan pada character encoding dan charset tag. Pick sebuah jawaban untuk setiap, lalu periksa.
Log perubahan
Diperbarui 18 Jul 2026.
Ringkasan editorial dan detail perubahan yang tercatat.Detail perubahan
-
Catatan perubahan terperinci saat ini tersedia dalam bahasa Inggris.
Perbandingan lengkap tidak tersedia — tidak ada cuplikan sebelumnya yang diarsipkan untuk revisi ini.