64

Normally UTF should be uppercased as it's an abbreviation. However, attributes in HTML are normally lowercased.

So, should it be: <meta charset="UTF-8"/> or <meta charset="utf-8"/>?
I know both work.

Thank you.

2 Answers 2

55

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

7
  • 5
    My vote is for lowercase though. Sort of like they've moved to with sql. I think it'll be mostly lowercase preferred in the long-term future.
    – Uncle Iroh
    Commented Jun 4, 2012 at 21:59
  • Awesome, thanks Ilanco. Do you happen to have the link to that quote?
    – Francisc
    Commented Jun 4, 2012 at 22:00
  • 3
    blog.codingoutloud.com/2009/04/08/… Seems to be of a guy that goes pretty deep into the topic.
    – Uncle Iroh
    Commented Jun 4, 2012 at 22:01
  • 1
    Ah, I had read that, but it's old and mostly oriented towards XML. Plus he recommends uppercase.
    – Francisc
    Commented Jun 4, 2012 at 22:03
  • 2
    This may not be relevant, but the general trend in everything (even outside of tech) these days has been to lowercase. HTML tags for example. Even in schools they prefer lowercase now.
    – rvighne
    Commented Jan 24, 2014 at 23:36
19

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.