# Stray start tag “footer”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/stray-start-tag-footer
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A `<footer>` placed after the closing `</body>` or `</html>` tag is stray, because the HTML parser allows no elements there.

Everything visible on a page goes inside `<body>`, the site footer included. Once the parser reads `</body>`, only whitespace, comments and the closing `</html>` tag may follow. Any element after that point is a parse error. Browsers recover by moving the footer back into the body as its last child, so the page usually looks right and the mistake goes unnoticed.

Templates are the usual source. A layout file closes the body before it includes the footer partial, or the page ends up with two `</body>` tags. The parser takes the first `</body>` as the end of the body, so a footer after it is stray even when another `</body>` follows. The validator doesn't flag that second `</body>`, so search the page for every `</body>` and keep only the last one.

Move the `<footer>` inside `<body>`, before its closing tag. It can sit directly in `<body>` as the page footer, or inside an `<article>` or `<section>` as the footer for that part of the page.

## Invalid example

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Contact us</title>
</head>
<body>
  <main>
    <h1>Contact us</h1>
    <p>Send us a message and we will reply within two days.</p>
  </main>
</body>
<footer>
  <p>Example Company, 123 Main Street</p>
</footer>
</html>
```

## Valid example

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Contact us</title>
</head>
<body>
  <main>
    <h1>Contact us</h1>
    <p>Send us a message and we will reply within two days.</p>
  </main>
  <footer>
    <p>Example Company, 123 Main Street</p>
  </footer>
</body>
</html>
```
