The HTML Doctype


Many years ago, there were many doctypes for HTML and XHTML documents. The doctypes were important for ensuring valid HTML or XHTML, but they were also complicated. Some of these doctypes are listed for reference on the historical page. The doctype for modern HTML (HTML 5) is shown below. This doctype is case-insensitive and is required for HTML 5 documents. Be sure to fill in your document's language in the value for the lang attribute.

<!DOCTYPE html>
<html lang="">
<meta charset="utf-8">


Toggle boilerplate view

Character Encoding

HTML Markup

In HTML 5, the meta element used to specify the character encoding of the document has been simplied from past versions and is shown below. This element should be included inside the document's head element to allow the browser to correctly decode the document.

<meta charset="utf-8">


If you have access to the web server settings, it is a better practice to set the Content-Type HTTP header. If this header is set, it is no longer necessary to include the above meta element.

Content-Type: text/html; charset=UTF-8