If I want to redirect to another page in my HTML file, do in have to place the meta tag in the head
or can I place it at the top of the file before the DOCTYPE? Thank you.
You can't place a meta
tag above the DOCTYPE. The DOCTYPE must always be the first element in an HTML document, and meta
tags must only be placed in the head
.
Documents must consist of the following parts, in the given order:
- Optionally, a single "BOM" (U+FEFF) character.
- Any number of comments and space characters.
- A DOCTYPE.
- Any number of comments and space characters.
- The root element, in the form of an html element.
- Any number of comments and space characters.
Source: http://www.w3.org/TR/html5/syntax.html#writing
For purposes of this question, the spec says that a document must start with a DOCTYPE and be followed by a root html
element. While a meta
tag might still work, there is no guarantee of it doing so today and continuing to do so in the future.