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
<meta charset>, <meta http-equiv>: a <head> element. If the http-equiv is not an encoding declaration, it can also be inside a <noscript> element, itself inside a <head> element. <meta name>: any element that accepts metadata content.
If the name attribute is set, the <meta> element provides document-level metadata, applying to the whole page. If the http-equiv attribute is set, the <meta> element is a pragma directive, providing information equivalent to what can be given by a similarly-named HTTP header.
meta tags live within the head tag of the HTML document. The head tag is used for configurating the HTML file. You use the head tag to add a title to the webpage, link to a CSS stylesheet, and define more information about the HTML document.
If the http-equiv attribute is set, the <meta> element is a pragma directive, providing information equivalent to what can be given by a similarly-named HTTP header. If the charset attribute is set, the <meta> element is a charset declaration, giving the character encoding in which the document is encoded.
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:
<!DOCTYPE html>
- Isn't that just nice and simple?<meta charset="utf-8">
- More concise, more betterererererer.../>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With