ajkaramba Posted September 23, 2013 Share Posted September 23, 2013 (edited) 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 September 23, 2013 by ajkaramba Link to comment Share on other sites More sharing options...
Ingolme Posted September 23, 2013 Share Posted September 23, 2013 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 More sharing options...
davej Posted September 23, 2013 Share Posted September 23, 2013 Is there any downside to closing everything? Link to comment Share on other sites More sharing options...
Ingolme Posted September 23, 2013 Share Posted September 23, 2013 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 More sharing options...
astralaaron Posted October 5, 2013 Share Posted October 5, 2013 Ignolme, are you saying in html5 we don't need to close tags like <img /> <hr /> etc. for the document to be valid? Link to comment Share on other sites More sharing options...
Ingolme Posted October 6, 2013 Share Posted October 6, 2013 There's no requirement to close empty elements in HTML Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now