The <!DOCTYPE> tag tells the browser what to expect. If it is a Transitional doctype it will tell the browser to use a non-standards mode. If it is a Strict doctype the browser will switch to standards mode. This tag should be placed first on the page, before the <html> tag also if you are using XHTML, this tag does not need to be closed.
Where/how To Use The <!DOCTYPE> Tag
| Use in head or body section? | Use before the <html> tag |
| Inline or Block level tag? | No level |
| HTML Tag Syntax? | <Tag> |
| XHTML Tag Syntax? | <Tag> |
Example - HTML 4.01
HTML 4.01 Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Transitional
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Notes
Use the right doctype that is most suitable for your site.
If no doctype is present the browser will process the page as Transitional.
'doctype' is 'document type'.

Comments