Home > ASP .NET > Web Development basics for ASP.NET Developers – What is DOCTYPE?

Web Development basics for ASP.NET Developers – What is DOCTYPE?

Most of us conveniently ignore the DOCTYPE in an ASP.NET Page, What is DOCTYPE in the context of web development?

It is an instruction to the web browser that

  • Defines which version of (X)HTML our document is actually using
  • Triggers a rendering mode in most of the families of browsers
    The most commonly used DOCTYPEs

HTML 4.01 Strict

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Not Allowed Not Allowed Not Required

HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Allowed Not Allowed Not Required

HTML 4.01 Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"&gt;

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Allowed Allowed Not Required

XHTML 1.0 Strict

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

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Not Allowed Not Allowed Required

XHTML 1.0 Transitional

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

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Allowed Not Allowed Required

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"&gt;

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Allowed Allowed Required

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;

Presentation, Deprecated elements (ex: FONT) Framesets Well formed XML
Not Allowed Not Allowed Required

HTML 5

<!DOCTYPE HTML>

Some rules

  • The doctype declaration should be the very first thing in an HTML document, before the <html> tag.
  • The doctype declaration must be exact (both in spelling and in case) to have the desired effect
    We saw about the versions / flavors of (X)HTML, now lets return to the rendering modes of the browsers.
    In Netscape and Internet Explorer 4 days CSS standards compliance was really patchy, but moving forward the newer browser version were getting closer to the standard. The browser vendors faced these major issues
  • allow web developers who knew their standards to choose which mode to use.
  • continue displaying old pages according to the old (quirks) rules.

Thus all browsers needed two modes: quirks mode for the old rules, strict mode for the standard.

    The right DOCTYPE declaration will trigger the strict rendering mode in most families of browsers.
    References & Further Reading:

http://www.w3.org/QA/Tips/Doctype

http://www.w3.org/QA/2002/04/valid-dtd-list.html

http://www.w3.org/QA/2002/04/valid-dtd-list.html

http://www.alistapart.com/articles/doctype/

http://www.quirksmode.org/css/quirksmode.html

http://www.quora.com/Without-a-version-number-in-the-HTML5-doctype-how-will-we-specify-future-versions-of-HTML

 

    Advertisements
    Categories: ASP .NET Tags: ,
    1. No comments yet.
    1. No trackbacks yet.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: