UI Development Training in BTM Marathahalli Bangalore

 Definition:  <!DOCTYPE>  Defines the Document type  ,"!" stands for         Exclamation mark and DOCTYPE stands for Document type

Description: The HTML document type declaration is known as DOCTYPE, is the first line of code required in every HTML or XHTML document.  The DOCTYPE declaration is an instruction to the web browser about what version of HTML the page is written in. This ensures that the web page is parsed the same way by different web browsers.

All the modern browsers like Firefox, Internet Explorer, Chrome, Safari, and Opera supports html5 doctype.

 


Syntax: 

  In HTML 5, the declaration is  

 <!DOCTYPE html> 

  In HTML 4, the declaration is 

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

            "http://www.w3.org/TR/html4/strict.dtd">


As you can see the syntax, the DOCTYPE for HTML5 is rather the most shortest declaration compared to HTML4 or other XHTML declarations due to lack of references to a DTD like we usually have a DTD URL as an attribute.

NOTE: <!DOCTYPE html>  Declaration is NOT  case sensitive

We can write any format like 



 But better to write in upper case or lower case to Avoid confusions   

For writing a code to start with first line as shown below example

Example:    HTML-5



Example:    HTML-4



 

EXPLANATION:

A DOCTYPE declaration appears at the top of a web page before all other elements. According to the HTML specification or standards, every HTML document requires a valid document type declaration to insure that your web pages are displayed the way they are intended to be displayed

The doctype declaration is usually the very first thing defined in an HTML document (even before the opening <html> tag); however the doctype declaration itself is not an HTML tag.

If you don't use a doctype in the starting of an HTML document, the browser goes to the quirky mode. In that case, you may find that certain content is not being displayed the way you marked them up. So, it is a good practice to start your HTML document with a doctype.

In the version, HTML 4.01, the usage of DOCTYPE declaration was to create a reference to a document type definition, since the version HTML 4.01 was completely based on a Standard Generalized Markup Language .

The document type definition  is responsible for specifying the rules for the Standard Generalized Markup Language so that the browser processes the content correctly. But in the HTML version, HTML 5 there isn’t any need for a reference to a document type definition (DTD) because HTML 5 is not based on a Standard Generalized Markup Language(SGML).


Comments

Popular posts from this blog

Web Development best institute in Bangalore

5 Reason to choose MEAN Stack Development