Thursday, June 19, 2014

Advanced HTML Structuring - !DOCTYPE

!DOCTYPE

Despite old existing sites, only the !DOCTYPE declaration is allowed for new sites.

Example:    <!DOCTYPE html>

Do not use any legacy !DOCTYPE any more, codes below are part of those.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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


Without a !DOCTYPE, IE9 and earlier versions display webpages in IE5(Quirks) mode. Also, if there is anything precedes the !DOCTYPE, for example, a comment.

Read more:
http://en.wikipedia.org/wiki/Quirks_mode (Quirks mode)
http://blog.whatwg.org/tag/doctype (Current standard)
http://www.w3.org/QA/2002/04/valid-dtd-list.html (Deprecated doctypes)

No comments:

Post a Comment