<head> in <body>


I work on this site for week : https://patrimoine.mediatheque-lecateau.fr/

I’ve trouble with some page, index.php and collection show.

Visually u can see marge in top and bottom of these page, because my header is loaded in my body, the doctype isn’t loaded at all. I don’t understand why only on these page, the header called is my own for each page (the well loaded as the wrong).

Thx for having a look.

The first place to look is, if you have customized the php files for those pages, whether you have placed the head() function inside the body tag.

Sure, I call header in index.php

<?php echo head(array('bodyid'=>'home', 'context' => 'main'));?>

my header :

<!DOCTYPE html>
<html lang="<?php echo get_html_lang(); ?>">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php if ($description = option('description')): ?>
    <meta name="description" content="<?php echo $description; ?>">
    <?php endif; 
    if (isset($title)) {
        $titleParts[] = strip_formatting($title);
    $titleParts[] = option('site_title');
    <title><?php echo implode(' &middot; ', $titleParts); ?></title>
    <?php echo auto_discovery_link_tags(); ?>
    <!-- Plugin Stuff -->
    <?php fire_plugin_hook('public_head', array('view'=>$this));?>
    <!-- Stylesheets -->
    queue_css_file(array('iconfonts', 'normalize', 'style','slideshow'), 'screen');
    queue_css_file('print', 'print');
    echo head_css();
    <!-- JavaScripts -->
    echo head_js(); ?>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/menu-mobile.js"></script>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/ssmenu-mobile.js"></script>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/cookiechoices.js"></script>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/slideshow/global.js"></script>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/slideshow/html5shiv.js"></script>
	<script type="text/javascript" src="https://patrimoine.mediatheque-lecateau.fr/themes/lecateau/javascripts/slideshow/jquery.amichels.slider.js"></script>
<?php echo body_tag(array('id' => @$bodyid, 'class' => @$bodyclass)); ?>
<?php fire_plugin_hook('public_body', array('view'=>$this)); ?>
<!-- French autorization for cookies -->
<script type="text/javascript" >  document.addEventListener('DOMContentLoaded', function(event){cookieChoices.showCookieConsentBar('Ce site utilise des cookies pour vous offrir le meilleur service. En poursuivant votre navigation, vous acceptez l\’utilisation des cookies.', 'J’accepte', 'En savoir plus', 'https://patrimoine.mediatheque-lecateau.fr/mentions-legales/');});</script>

<div id="wrap">
	<header role="banner">
		<div id="site-title">
			<a href="https://patrimoine.mediatheque-lecateau.fr/" alt="Patrimoine du Cateau"><img src="https://patrimoine.mediatheque-lecateau.fr/files/original/fond_bandeau_entete.png" /></a>

		<div id="conteneur_nav">
		<nav id="top-nav" class="top" role="navigation">
				$navArray = array();
				$navArray[] = array('label'=>'Accueil', 'uri'=>url('')); // Home
				$navArray[] = array('label'=>'Découvrir','uri'=>url('patrimoine-du-cateau'), 'id'=>'patrimoine');
				$navArray[] = array('label'=>'Les fonds', 'uri'=>url('collections'));
				$navArray[] = array('label'=>'Tous nos contenus', 'uri'=>url('items'));
				$navArray[] = array('label'=>'Expositions', 'uri'=>url('exhibits'));
				$navArray[] = array('label'=>'Contact', 'uri'=>url('contact'));
				echo nav($navArray);

		<div id="search-container" role="search">
			<?php if (get_theme_option('use_advanced_search') === null || get_theme_option('use_advanced_search')):
					echo search_form(array('show_advanced' => true));
					echo search_form();
		<?php fire_plugin_hook('public_header', array('view'=>$this)); ?>

	<!-- If we are in simple page, we show the particular nav. -->
	$jsSetActiveClass = "<script>
		var d = document.getElementById('menu-patrimoine').parentNode;
		d.className += ' active';
		$parentPage = get_current_record('simple_pages_page', false);
		if($parentPage) {
			$patrimoinePage = is_page_childOf_patrimoine_page($parentPage);
		// si la page courante est une fille de la page de slug 'patrimoine-du-cateau' alors on affiche le sous-menu patrimoine
		if($patrimoinePage) {
			$resArray = simple_pages_get_links_for_children_pages($patrimoinePage->id, $sort = 'order', $requiresIsPublished = true);
			if(count($resArray) > 0) {	
				$navArray = array();
				foreach ($resArray as &$value) {
					$navArrayEx = array();
					if($value['pages']) {
						foreach($value['pages'] as &$subVal) {
							$navArrayEx[] = array('label'=>$subVal['label'], 'uri'=>$subVal['uri']);
					$navArray[] = array('label'=>$value['label'], 'uri'=>$value['uri'], 'pages'=>$navArrayEx);
				echo('<div id="sub-nav"><nav id="sousmenu" class="ssmenu" role="navigation">'.nav($navArray).'</nav></div>');
			echo $jsSetActiveClass;
	<div id="content" role="main" tabindex="-1">
			if(!is_current_url(WEB_ROOT)) {
			  fire_plugin_hook('public_content_top', array('view'=>$this));

Now, in Firefox only collection/show.php is bugged (own & default).
BUT I try with IE (W7) & Chrome and the head is allways in the body, I should done something wrong with the call, I don’t understand

Sounds like the best plan is to look back at how other themes do it, and follow those patterns. I think that calling head() will insert the head content wherever you call it. So, if there’s a <body> HTML tag above where you echo head(), that will lead to problems.

I see online that it should be DOM error that’s why <!DOCTYPE html> was cleared.

So I restart on new theme step by step, error goes out, pb resolved !

Thx for your attention.