Jump to content

HTML5 or XHTML document?


ajkaramba

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 comment
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 comment
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 comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...