Doctype Usage
- In HTML 4.01, the DOCTYPE declaration refers to a document type definition (DTD), which defines the structure and legal elements of an XML document.
- SGML Basis: HTML 4.01 is based on Standard Generalized Markup Language (SGML), necessitating a reference to a DTD in the DOCTYPE declaration.
- Strict DTD: This is used for web pages excluding outdated attributes and elements, promoting the use of CSS for styling and layout.
- Transitional DTD: This allows the use of deprecated elements and attributes, easing the transition from older HTML versions to more modern practices.
- Frameset DTD: Specifically used for web pages that utilize frames, defining the structure and permissible elements for such layouts.
Example: In this example, we will see, an HTML program with a doctype declaration:
<!DOCTYPE html>
<html>
<body>
<h1>
w3wiki
</h1>
<h2>
This is HTML5 Doctype Tag
</h2>
</body>
</html>
Output:
Below is the list of some common doctype declaration for different version of HTML and XHTML:
HTML Doctypes
HTML Doctypes declared at the beginning of HTML documents, inform browsers about the document type and version, ensuring correct rendering. They aren’t HTML tags but provide essential information. The most common doctype is <!DOCTYPE html>, used for HTML5, ensuring modern web standards.
Contact Us