HTML5 new Doctype and Charset

HTML5 new Doctype and Charset

HTML5 defines an HTML syntax that is compatible with HTML4 and XHTML1 documents published on the Web. The HTML syntax of HTML5 requires a DOCTYPE to be specified to ensure that the browser renders the page in standards mode. The DOCTYPE declaration is <!DOCTYPE html> and is case-insensitive in the HTML syntax.

For the HTML syntax of HTML5, setting the character encoding is done by using a meta element with a charset attribute that specifies the encoding within the first 1024 bytes of the document. E.g. <meta charset=”UTF-8″> could be used to specify the UTF-8 encoding. This replaces the need for <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> although that syntax is still allowed.

Following example of a HTML5 web page illustrates the usage of new doctype and charset

<!doctype html>

<html>

<head>

<meta charset=”UTF-8″>

<title>Example document</title>

</head>

<body>

<p>Example paragraph</p>

</body>

</html>

Get industry recognized certification – Contact us

Menu