Customer Street advice on using the HTML DOCTYPE tag in your website coding.
What is the DOCTYPE Tag ?
The <!DOCTYPE> declaration is the very first thing in your document.
It is placed before the <html> tag and this tag tells the browser which HTML or XHTML specification the document uses. Note that this tag does not have a close tag.
In HTML 4.01 the DOCTYPE tag specifies three document types: Strict, Transitional, and Frameset.
DOCTYPE HTML Strict
Use this when you want clean markup, free of presentational clutter. Use this together with Cascading Style Sheets (CSS)
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
DOCTYPE HTML Transitional
The Transitional DOCTYPE includes presentation attributes and elements that W3C expects to move to stylesheets. Use this when you need to use HTML’s presentational features because your readers don’t have browsers that support Cascading Style Sheets (CSS)
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
DOCTYPE HTML Frameset
The Frameset DOCTYPE should be used for pages with frames. The Frameset DOCTYPE is equal to the Transitional DOCTYPE except for the frameset element replaces the body element
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
DOCTYPE XHTML Strict
Use this DOCTYPE when you want clean markup, free of presentational clutter. Use this together with Cascading Style Sheets (CSS)
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
DOCTYPE XHTML Transitional
Use this DOCTYPE when you need to use XHTML’s presentational features because your readers don’t have browsers that support Cascading Style Sheets (CSS):
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
DOCTYPE XHTML Transitional
Use this DOCTYPE when you want to use frames!
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
Example
Why is the <!DOCTYPE> tag important
This tag is very important as it declares to both internet browsers and search engines the code language your page is written in. If you do not delare the DOCTYPE you are using then this may result in your visitors not being able to view your website correctly or even search engines not ranking you in their searches.