This forum is now read-only. Please use our new forums at discuss.codecademy.com.

HTML Basics Forum

View Course » View Exercise

912 points
53b7ea14548c352e3400116c_164074792
Submitted by
Noah Lovelady-Allen
about 3 years ago

Why do we have to use <!DOCTYPE html><html></html>?

It renders whether or not we do it. The instructions say we have to include it, but the code works just fine without it.


2 votes

permalink

The
<!DOCTYPEhtml>
shows the computer that this document is using HTML.
The
<html>
</html>

Is just the starting and ending tags for html.

409 points
53653471631fe9696d002098_4143800
Submitted by
Angelblade
about 3 years ago

3 Comments

53b7ea14548c352e3400116c_164074792 Noah Lovelady-Allen about 3 years ago

Then why does the webpage work without them?

53653471631fe9696d002098_4143800 Angelblade about 3 years ago

The main reason is that it is a container for all of the HTML elements and represents the root of the website. The only reason why it probably works without it is that you are using an HTML editor. If you don't do that on a normal page, then the code will not work.

Fb6f13fcbef596b703d337caf56196d0?s=140&d=retro Joel.Miles925 almost 3 years ago

You are totally right.


-5 votes

permalink

I would guess that it is proper practice and some web browsers could possibly detect if it is not present and realize they are trying to open something in an unrecognized format.

968 points
5296b33aabf821857b0015d6_980210769
Submitted by
turkey3
about 3 years ago

1 Comment

53653471631fe9696d002098_4143800 Angelblade about 3 years ago

Thats not it. I answered it below.