Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why <meta> and <title> tags are ordered in this way?

 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 <title>Test Title</title>
 <meta name="description" content="">
 <meta name="viewport" content="width=device-width">

Why is two meta tags always go before title and others afterwards?

Is there any reason (compatibility, coding references or rules) I can't place all the meta tags before title?

like image 527
Denis Bobrovnikov Avatar asked Dec 01 '25 09:12

Denis Bobrovnikov


2 Answers

The browser needs to know the character encoding as soon as possible. Other elements (including the title) can contain characters which only have meaning (or the correct meaning) in the specific encoding being used.

There is no need for any other meta elements to appear before the title.

Is there any reason (compatibility, coding references or rules) I can't place all the meta tags before title?

The sooner the title appears, the sooner the browser can display it (in the title bar, tab, etc).

like image 191
Quentin Avatar answered Dec 02 '25 23:12

Quentin


It's partly un-necessary, but from a strictly theoretical view, it makes sense.

If you consider you first tell the browser it's a <HTML>, document it's dealing with, then that the content/characterset is UTF-8, so then the browser will know how to properly treat the title text, with the correct character set.

like image 37
Alexander Wigmore Avatar answered Dec 03 '25 01:12

Alexander Wigmore