# Legacy doctype. Expected “<!DOCTYPE html>”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/legacy-doctype-expected-doctype-html
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A legacy doctype triggers this warning because the document uses an older or non-standard `<!DOCTYPE>` declaration instead of the simple HTML5 doctype.

The HTML5 doctype is `<!DOCTYPE html>`. It is case-insensitive, short, and tells the browser to render the page in standards mode. Older doctypes, such as those referencing XHTML 1.0 Transitional, HTML 4.01 Strict, or any DTD URL, are considered legacy. They still work in browsers, but the W3C validator flags them because the modern HTML standard requires only `<!DOCTYPE html>`.

Common legacy doctypes that cause this warning include:

- `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">`
- `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`
- `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`

The fix is to replace the entire doctype line with `<!DOCTYPE html>`. No DTD reference or public identifier is needed.

## HTML examples

### Before (legacy doctype)

```html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
    <title>Example</title>
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>
```

### After (HTML5 doctype)

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Example</title>
  </head>
  <body>
    <p>Hello world</p>
  </body>
</html>
```
