# doctype-first

> Ensures the doctype declaration appears before any non-comment content in HTML documents.

Doctype must be declared before any non-comment content. Comments and whitespace are allowed before the DOCTYPE declaration.

Level: Error

## Config value

[Section titled “Config value”](#config-value)

* `true`: enable rule
* `false`: disable rule

### The following patterns are **not** considered rule violations

[Section titled “The following patterns are not considered rule violations”](#the-following-patterns-are-not-considered-rule-violations)

```html
<!DOCTYPE html>
<html></html>
```

```html
<!-- Comment before doctype -->
<!DOCTYPE html>
<html></html>
```

### The following patterns are considered rule violations

[Section titled “The following patterns are considered rule violations”](#the-following-patterns-are-considered-rule-violations)

```html
<html></html>
```

```html
<div>Content before doctype</div>
<!DOCTYPE html>
<html></html>
```

### Why this rule is important

[Section titled “Why this rule is important”](#why-this-rule-is-important)

The DOCTYPE declaration is required for HTML5 compliance and to ensure that the document is parsed correctly.