Meta tags explained: http-equiv and charset

What's better? 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 the Viewport and meta http-equiv meta tags do not receive / "> closing tags, since charset and other meta tags have ... why?

thanks

+6
source share
2 answers

The second is better, since it is more concise. It has been standardized this way in HTML5.

As for tags ending in /> : it doesn't matter what tag it is. No tag should close as in HTML5. In the old days of XHTML, all of these tags had to be closed in the same way that XHTML was associated with XML.

So, takeaway in this way:

  • Use HTML5 doctype: <!DOCTYPE html> - Isn't it simple and easy?
  • Definitely use <meta charset="utf-8"> - more concise, more advanced ...
  • No need to close tags />
+12
source

Link: 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 second is small (html5) and the last

0
source

Source: https://habr.com/ru/post/920973/


All Articles