A DOCTYPE declaration appears at the top of a web page before all other elements. According to the HTML specification or standards, every HTML document requires a document type declaration to insure that your pages are displayed the way they are intended to be displayed. The doctype declaration is usually the very first thing defined in an HTML document; however the doctype declaration itself is not an HTML tag. The DOCTYPE for HTML5 is very short, and case-insensitive.
<!DOCTYPE html>
Doctypes from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD, but they are obsolete now. With HTML5 this is no longer the case and the doctype declaration is only needed to enable the standard mode for documents written using the HTML syntax.
You can use the following markup as a template to create a new HTML5 document that uses the latest HTML5 doctype declaration.
Note:The doctype declaration refers to a Document Type Definition (DTD). It is an instruction to the web browser about what version of the markup language the page is written in. The W3C provides DTDs for all HTML versions.
The following section contains the different doctypes from the previous version of HTML. Although using the HTML 4.01 doctypes are still a valid way to create DOCTYPE declaration, but they are no longer considered a best practice.
The HTML 4.01 Strict DTD includes all elements and attributes that have not been deprecated or do not appear in frameset documents. For documents that use this DTD, use the following DOCTYPE declaration:
The HTML 4.01 Transitional DTD includes everything in the strict DTD as well as deprecated elements and attributes but excludes the frameset content. For documents that use this DTD, use the following DOCTYPE declaration:
The HTML 4.01 Frameset DTD includes everything in the transitional DTD, as well as also allows the use of frameset content. For documents that use this DTD, use the following DOCTYPE declaration:
Warning:The <frameset>
and <frame>
elements has been removed from HTML5 and should no longer be used. Therefore, frameset DTD is no longer valid.
XHTML 1.1 is the most current finalized revision of XHTML 1.0 Strict, introducing support for XHTML Modularization, which means that you can add modules (for example, to provide Ruby support for Chinese, Japanese, and Korean characters). For documents that use this DTD, use the following DOCTYPE declaration:
Tip:Must add a doctype to your HTML/XHTML document and use the W3C's Validator to check the markup or syntax error before publishing online.
How Many People Visit |
|