Should HTML meta charset be lowercase or uppercase?
Solution 1:
The value for charset is case-insensitive.
From spec.whatwg.org
The charset attribute specifies the character encoding used by the document. This is a character encoding declaration. If the attribute is present, its value must be an ASCII case-insensitive match for the string "utf-8".
Link to full document: https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset
Solution 2:
As per the W3C:
A case-insensitive match for any character set name for which the IANA [Character Sets] registry has a Name or Alias field labeled as “preferred MIME name”; or, if none of the Alias fields are so labeled, a case-insensitive match for a Name field in the registry.
The specification does not specifically provide for a canonical case. Previously, I would have suggested you just use UTF-8
(from the registry), however the world is moving to lowercase and I now prefer utf-8
as it aligns better with all your other HTML.