Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

What is the difference between <!doctype html> and Index.html?

I never understood the difference. If you save the file in .html why bother declaring the document type?

3 Answers

There are different standards/types of HTML documents. The extension itself is not enough for layout engines to deduce which one is being used.

The doctype you mention is for HTML5.

You can find more about it here.

The doc type is stating what document type you will be using. Index.html is the name of your homepage on your site. The server will look for a page that is a homepage, so when the user is on your website, the index.html will be shown first to the user.

One is a file name and the other is a doctype declaration that you put in the first line of your file so your browser knows how to process it.

There are different versions of html. The doctype you posted is the html5 doctype. Other index.html files might have an older doctype if they were using an older version of html.