Should HTML meta charset be lowercase or uppercase?

前端 未结 2 1267
攒了一身酷
攒了一身酷 2021-02-03 17:46

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

So, should it be:

相关标签:
2条回答
  • 2021-02-03 18:10

    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.

    0 讨论(0)
  • 2021-02-03 18:22

    The value for charset is case-insensitive.

    From w3.org

    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.

    Link to full document: http://www.w3.org/TR/html-markup/meta.charset.html

    0 讨论(0)
提交回复
热议问题