WeekendCoder
WeekendCoder

Reputation: 1035

HTML5: Meta charset before title?

I often see this:

<head>
<meta charset="utf-8">
<title>Title</title>
...
</head>

Is it important to put the chartset definition BEFORE the the title tag?

Thanks!

Upvotes: 7

Views: 2384

Answers (1)

mnagel
mnagel

Reputation: 6854

yes it is, see https://code.google.com/p/doctype-mirror/wiki/MetaCharsetAttribute

In order for all browsers to recognize a <meta charset> declaration, it must be

  • Within the <head> element,
  • Before any elements that contain text, such as the <title> element, AND
  • Within the first 512 bytes of your document, including DOCTYPE and whitespace

Upvotes: 9

Related Questions