innhyu innhyu - 5 months ago 8
HTML Question

Chrome puts everything HTML tag between HEAD and BODY into BODY

So my code goes something like

<!DOCTYPE HTML>
<html>
<head></head>

<header> something </header>

<body> </body>
</html>


and whenever I load this in chrome, chrome puts the header tag inside the body tag which is frustrating me. I tried this in Safari and the source shows to be fine, as I intended so.

Why is chrome doing this?

Answer

Everything that is supposed to be visible belongs in the <body>. Thus Chrome is actually fixing your HTML for you. Validate your HTML code https://validator.w3.org/

Your code should look like, in order to be valid :

<!DOCTYPE HTML>
<html>
   <head>
     <title>Some Title</title>
   </head>
   <body>
      <header> something </header>
   </body>
</html>