Html help

please tell me anyone why do I need to write <!..doctype> at the top of html?

what is that for?

It is so the browser knows what html version the page is written. Some doctypes do things in different ways and if not stated the browser may render the page incorrectly.

The types are listed here

If you are using HTML 2 through HTML 4 then that tag is an SGML tag that identifies that the language the page is written in is a version of HTML that follows the SGML standards. If you use the longer version of the doctype in those cases then you are identifying exactly which version of HTML the page uses and attach the actual SGML specification for that version that the page could use to render the content (if browsers actually used the standards to determine how to process the HTML). With HTML 5 it is merely an HTML tag that identifies that your page follows the standards and is not to be rendered in quirks mode.

With XHTML 1 it has the same meaning as for HTML 2 through 4. For XHTML 5 you do not need that tag at all as version 5 does not follow the SGML standard and XHTML does not have a quirks mode.

As felgall said above, if you don’t have a doctype declaration like that, the browser goes into “quirks mode”. That basically means that the browser will assume you are using really, really old and outdated coding practices, and will thus render the page like browsers did back in the very old days.

<!DOCTYPE> declaration must be the very first thing in your HTML document, before the <html> tag.The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

This code is what html version are using you on the page. Some doc types are differently so browser may assume the page incorrectly.

Because browser knows what HTML version the page is written.

Jennifer

<!doctype html>
is the tag of the html 5 which is latest developed by the html for the design of the websites for the mobiles and tablets.