Here is the one quick article about DocType in HTML.Generally the Most common question asked in an interview is What is DocType and why it’s important in HTML.
DocType is the short form of “Document Type Definition”.It must be the first statement on a web page which appearing even before any spacing or carriage returns.DocType is not an HTML tag.To know your web browser about the version of HTML you are using ,the doctype comes in because it’s important for web browser to identify the version of HTML so The doctype used to specify which version of HTML the browser should expect to see.With version information, Browser decides how to render code on the screen.
Let’s see one example:
1 2 3 4 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
The doctype above statement that we’re using XHTML 1.0 Strict, and includes a URL to which the browser can refer and URL points to the W3C’s specification for XHTML 1.0 Strict.
Let’s have a look with other DocTypes
HTML 4.01 Transitional
It has an all elements and attributes of HTML 4 Strict and with presentational attributes, deprecated elements and link targets.
HTML 4.01 Strict
It has an all elements and attributes of HTML 4 without presentational attributes, deprecated elements and link targets.
XHTML 1.0 Transitional
It’s same as HTML 4.01 Transitional but with the support of XML.
XHTML 1.0 Strict
It’s same as HTML 4.01 Strict but with the support of XML.
XHTML 1.1
It’s same as XHTML 1.0 Strict but allows to add modules.
XHTML Mobile 1.0
It is useful and better to use when the site wants with Mobile support.It’s same as XHTML 1.0 with some XHTML modules and Mobile web application supports.
HTML 5
HTML5 use and it is not require a reference to a DTD.
I hope this explanation is enough to answer the DocType.Also like other post, see here:
Clean HTML content in PHP
Convert RGB to Hex HTML code in PHP
Comments (6)