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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top