Doctype importance and why we use doctype

Hi,

I am using Colorbox and other JQuery libraries in my project.

Doctype is important for JQuery library like Colorbox.

I want to know importance and why we need doctype in document.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

-Thanks
Zohaib.

Basically, if you have a doctype on your page, the browser sees it and thinks—OK, this web designer has some clue about what he’s doing, so we’ll render the page according to the prevailing web standards. If there’s no doctype, the browser might decide to display your page in “quirks mode”, as if it were built last century, and thus your layout will break in certain ways.

It doesn’t really matter which doctype you use. These days, it’s common to use the so called “HTML5” version, which is more of a generic doctype:

<!DOCTYPE html>

which ends up like this in the document:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

Doctype help browser understand if the page is written using strict, transitional or frameset type html. Depending upon this declaration the page code will be validated in w3c validator.

Also doctype is necessary to make few elements of html work properly. It is an idea practice to include the doctype in your html page.

Doctype specify the web standard you have used for writing code of your website.Each doctype has different rules and constraints