What is the correct way to declare an HTML5 Doctype.

The standard has been simplified because the previous doctypes were too cryptic. The new doctype is simply <!DOCTYPE html> . You may wonder why it is not <!DOCTYPE html5> but it is simply because it is just an update to the standard of HTML and not a new version of anything. As you can see below, all elements can now have a language attribute.

The <html> element is the root element of a document. Every document
must begin with this element, and it must contain both the <head> and
<body> elements.

It is considered good practice to specify the primary language of the
document on this element using the lang attribute.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Hello World</title>
    </head>
    <body>
        <h1>Hello World</h1>
        <p>
            Jamie was here.
        </p>
    </body>
</html>

More info: https://dev.w3.org/html5/html-author/#doctype-declaration

Leave a Comment

tech