Alex Rivera | Logout

Is it valid HTML5 to use a single tag for a div?

Asked 2010-10-04T02:23:41.487
25

For example: <div/> instead of <div></div>. I did this and apparently the HTML5 validator passed this as valid. I was wondering it this is actually true?

PS: I'm serving page as application/xhtml+xml

Edit
Report

1 Answer

26

This is not valid HTML 5 (HTML does not allow shorttags, the equivalent HTML construct is a single opening div tag). It is valid XHTML 5, as it is valid XML.

The reason why you might see this pass through a validator just fine is because of what you stated:

PS: I'm serving page as application/xhtml+xml

Which means that you tell the validator that it must treat your markup as XML. In other words your page is not HTML 5 at all.

answered 2010-10-04T02:33:11.147

Your Answer