Close <meta> tags in HTML5 or not?

I’m confused as to whether or not meta tags should be closed or not in HTML5. It seems like it should be and does this, but most other sites done by well known developers do not close it.

Which one’s correct?

<meta charset="utf-8">


<meta charset="utf-8" />

take a look at this.

in fact you are asking what to use in html5: html syntax or xhtml syntax. and for xhtml, the charset value belongs to the xml declaration:

<?xml version="1.0" encoding="UTF-8"?>

more info here ([I]2. Syntax[/I]). also, i recommend you reading this [URL=“”]thread.

If you are writing HTML, you do not need to self-close any elements. Spot elements, such as <img>, <meta>, <link>, <br> etc remain as spot elements, just as they were in earlier forms of HTML.

If you are writing XHTML, all elements need to be closed, and this can either be done by <meta …></meta> (which won’t work on a lot of older browsers) or <meta … /> (which will).

Keeping things simple, their both correct. I always self-close elements because I prefer the XHTML method of syntax (and the refusal to allow errors), but using conventional classic HTML non-closed code is equally valid, just be sure you’re consistent with whatever you use and it shouldn’t be too much of an issue.

I highly discourage using the XML Doctype in XHTML as older versions of IE (6 especially) will trigger quirks mode and make your entire design fall to it’s feet. :slight_smile:

Of course if you are actually going to use XHTML then that IE6 issue doesn’t apply since the only version of IE to support XHTML so far is IE9.

Also you really shouldn’t have the space before the /> if you are going to use XHTML syntax since served as XHTML it is completely unnecessary and if served as HTML it only causes issues in Netscape 4 and earlier browsers.

in arguments around this forum, some have said to me that xhtml equals xml, others that xhtml is an application of xml. all this true.

what you’re proposing defeats the whole (x)html-xml point :slight_smile: , but it’s a toss off between practicality and normality.
frankenstein web :wink:

Well technically Internet Explorer defeats the whole purpose of XHTML so unless you want to sacrifice a huge proportion of your audience who use IE6-8, 99% of all the XHTML being implemented on the web is done so in such a way that it’s invalid, incompatible or pointless, so it’s a losing battle :wink:

then probably i should point out (again) to rezzner this thread :slight_smile:

It defeats the whole purpose of HTML 5 as well since IE10 is going to be the earliest version of IE that can possibly support that properly - IE9 can at best support it as well as IE5 supported CSS 2 - with all the same potential problems that caused.