Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    comment tag help?

    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?
    Last edited by resin; 06-09-2012 at 06:31 PM.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 663 Times in 652 Posts
    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.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts