NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

"<!DOCTYPE>" declarations should appear before "<html>" tags

Web:DoctypePresenceCheck

The <!DOCTYPE> declaration tells the web browser which (X)HTML version is being used on the page, and therefore how to interpret the various elements.

Validators also rely on it to know which rules to enforce.

It should always preceed the <html> tag.

Noncompliant Code Example

<html>  <!-- Noncompliant -->
...
</html>

Compliant Solution

<!DOCTYPE html>
<html>  <!-- Compliant -->
...
</html>