View Full Version : comment tag help?

06-09-2012, 04:35 PM
Where is the earliest location you can place a comment tag in a page's code? I've heard you shouldn't place anything before doctype, but how soon after that can it be placed, without causing any possible bad or buggy behavior? For instance, could a comment tag exist between the doctype and opening html tag? Also, can comment tags be placed at the very end, after the closing html tag?

06-10-2012, 12:11 AM
Since the comment tag is an HTML tag it should only be used inside of the <html> tag. Anything outside the <html></html> isn't HTML by definition. (the <DOCTYPE> tag is SGML).

Browsers might accept a comment outside of the HTML but there is nothing to say that they have to - which is why versions of IE not recognising the DOCTYPE tag when it was preceded by an illegally placed comment cannot be considered to be a bug.