6
votes

Which is best? And what is the difference?

<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

or

<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

Another thing, I see that Viewport meta tags and meta http-equiv tags do not get the /> closing tags as charset and other meta tags have...why is that?

Thank you

2

2 Answers

12
votes

The second one is better, since it's more concise. It was standardized that way in HTML5.

As for the tags ending in />: It makes no difference what tag it is. No tag has to close like that in HTML5. In the olden days of XHTML, all these tags had to close like that, since XHTML is related to XML.

So, the takeaway is thus:

  1. Use an HTML5 doctype: <!DOCTYPE html> - Isn't that just nice and simple?
  2. Definitely use <meta charset="utf-8"> - More concise, more betterererererer...
  3. No need to close your tags with />
0
votes

Reference : http://www.w3schools.com/html5/tag_meta.asp

HTML 4.01: meta http-equiv="content-type" content="text/html; charset=UTF-8"
HTML5: meta charset="UTF-8"

so the 2nd one is small(html5) and latest