Jump to content

HTML5 or XHTML document?

Recommended Posts

Hello!I have to correct syntax errors in a document that looks something like this: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Title</title></head><body><p>content</p></body></html>There are a lot of syntax errors in the full verision of the document, but some end tags like </p> are also missing. I don't know if I'm supposed to add tags like </p> because if this document is HTML5 it isn't necessary.When I validate the document at http://validator.w3.org/check it says that it is HTML5, but <html xmlns="http://www.w3.org/1999/xhtml"> makes me wonder...Can anyone please tell me if this is a HTML5 or XHTML document?


I usually close all tags but since I'm supposed to correct syntax errors I'm not sure if I should close all tags because the validator (which says that it's HTML5) doesn't say that a missing end tag is a syntax error. I mean, if it's HTML5 my teacher shouldn't be allowed to complain about it...


Do you think I will fail the assignment if I don't close all tags? Thanks!

Edited by ajkaramba
Link to post
Share on other sites

The <!DOCTYPE> declaration indicates it's an HTML 5 document. Despite being valid to leave unclosed <p> elements, I recommend closing them all anyways.

HTML 5 is allowed to be serialized as XML, that's when you would use the xmlns attribute.

If you're not intending the document to be read by XML parsers, I would advise against closing empty elements with />. Empty elements are <br>, <img>, <link> and others like that.

Link to post
Share on other sites

Is there any downside to closing everything?

The file to be downloaded is larger.


As for empty tags, the reason I don't close them is because the validator interprets it as the old SGML shorttag syntax.

Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...