Robert Kingston
Robert Kingston

Reputation: 369

HTML elements in <head> load within the <body>

A site I am working on declares all of the necessary information within the head of the document, but all the elements within the , show up within the element when I inspect the page in Chrome and Firefox. Here is the page:

view-source:http://www.ozzytyres.com.au/store/tyres/kumho-175-70r13-82t-kr21.html

I can't see why it's parsing the header element within the body like that.

Upvotes: 0

Views: 114

Answers (2)

Carl0s1z
Carl0s1z

Reputation: 4723

Is it true that you are loading your head with an include?

Beacause if so, read this topic: include() messing up HTML structure

It says that you have 2 options:
- Copy and paste it in every file
- Create unique pages with dynamic content

Upvotes: 3

Alohci
Alohci

Reputation: 82986

Immediately before the <title> tag, there is a UTF-8 encoding of a zero-width no-break character in your source. This is probably caused, as C Travel suggests, by a bad include of a file that has a UTF-8 Byte Order Mark (BOM) at the start of it. (The same character serves as both zero-width no-break and BOM). Alternatively, it could have come from a cut and paste between editors that don't understand BOMs sufficiently.

The zero-width no-break character is seen as a displayable character in the markup by the parser, and therefore thinks that the <body> tag must have been omitted. So it infers the body element, and puts everything that follows into the body section.

To fix it, you must fix your markup to not include the zero-width no-break character.

Upvotes: 2

Related Questions