Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should HTML meta charset be lowercase or uppercase?

Tags:

html

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.

like image 844
Francisc Avatar asked Jun 04 '12 21:06

Francisc


People also ask

Should HTML tags be uppercase or lowercase?

Tag names for HTML elements may be written with any mix of lowercase and uppercase letters that are a case-insensitive match for the names of the elements given in the HTML elements section of this document; that is, tag names are case-insensitive.

Should UTF-8 be capitalized?

Sometimes you'll see the encoding as “UTF-8” or “UTF-16” (all caps), sometimes as “utf-8” or “utf-16” (lowercase). Which is correct? Or are both correct? The short answer is that the uppercase variant is preferred, but both are allowed, though that does not ensure that both variants are widely supported.

Is meta charset UTF-8 needed?

It doesn't matter which you use, but it's easier to type the first one. It also doesn't matter whether you type UTF-8 or utf-8 . You should always use the UTF-8 character encoding. (Remember that this means you also need to save your content as UTF-8.)


1 Answers

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

like image 67
ilanco Avatar answered Oct 03 '22 09:10

ilanco