3

I use Initializer to quickly generate HTML5 + Boostrap boilerplates and am curious why the HTML doc that is created does not have an opening <html> tag?

Here is the top portion of what Initializr generates for me:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>

I have deployed a few websites using Initializr and haven't run into problems. Do you need an opening <html> tag?

cheshireoctopus
  • 1,670
  • 1
  • 22
  • 31
  • 7
    there's 4 `` tags there. They're fenced in by IE conditional tags, but there's still 4 tags in there. just because they have a class attribute doesn't turn into `` – Marc B Apr 11 '14 at 16:34
  • 4
    What do you mean that it doesn't have an opening `html` tag? I see `html` tags in your code. – putvande Apr 11 '14 at 16:34
  • 2
    There is only one `` tag in the code. Text in comments does not constitute a tag. IE processes certain types of comments in a nonconforming way, but that’s a different issue. – Jukka K. Korpela Apr 11 '14 at 17:17

1 Answers1

10

From the HTML 5 Specification:

An html element's start tag can be omitted if the first thing inside the html element is not a comment.
An html element's end tag can be omitted if the html element is not immediately followed by a comment.

So, yes, the tag is optional.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
tkone
  • 22,092
  • 5
  • 54
  • 78
  • 1
    Yet, OP's code doesn't actually omit it, nor it can be omitted if you want to assign a class or ID to it from HTML. – John Dvorak Apr 11 '14 at 16:36
  • 1
    It is correct, the code posted does contain an `` tag, but the question specifically asks if it's required. Ironic that they're not actually using code which supports the question... – tkone Apr 11 '14 at 16:38