HTML Doctype declaration
The HTML Doctype declaration is an essential part of an HTML document. It defines the version of HTML being used and instructs the web browser how to interpret the HTML code. The Doctype declaration is placed at the very beginning of an HTML document, before the
The Doctype declaration is written using a specific syntax and follows the following general structure:
doctype_name represents the specific HTML version or Document Type Definition (DTD) that the document adheres to. Different versions of HTML have different Doctype declarations.
Here are some common Doctype declarations used in HTML:
- HTML5 Doctype:
The HTML5 Doctype declaration is used for modern HTML documents. It is the simplest and most commonly used Doctype for contemporary web development.
- HTML 4.01 Strict Doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The HTML 4.01 Strict Doctype is used for documents that adhere to the strict rules of HTML 4.01. It ensures more consistent rendering across different browsers.
- HTML 4.01 Transitional Doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The HTML 4.01 Transitional Doctype allows for more relaxed rules and includes features that were present in older versions of HTML.
- XHTML 1.0 Strict Doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The XHTML 1.0 Strict Doctype is used for documents that adhere to the strict rules of XHTML 1.0, which is a stricter and XML-based version of HTML.
- XHTML 1.0 Transitional Doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">