Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All my <head> content is being rendered/outputted on <body>

Tags:

php

wordpress

So this is my first post! I've just created the account, but I always check on here to solve my problems. I've found others with the same problem but the solutions haven't been working for me.

So I have on the .PHP file all the content correctly placed on the head tag but for some reason it is going into the body tag leaving my first one empty.. And it adds a strange "

" (text space) on the beginning of the body. What could it be?

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen">
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>">
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>">
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
</head>
<body>
like image 791
Derik Avatar asked Sep 08 '12 16:09

Derik


4 Answers

Easy Solution

  1. Open your head containing file with Notepad++
  2. Click on encoding, select Encode in UTF-8 Without BOM It fixes the issue.
like image 65
Kerim Avatar answered Nov 08 '22 20:11

Kerim


This is most likely caused by an error introducing some text content into the head area.

It is very hard to identify where that is given the PHP instead of the generated HTML, but a validator should pick it up.

like image 41
Quentin Avatar answered Nov 08 '22 22:11

Quentin


(Posted on behalf of the OP.)

Fixed. The problem was that the files were with BOM (Byte-Order Mark). Re-saving all files without the BOM solved it.

like image 1
halfer Avatar answered Nov 08 '22 20:11

halfer


The simple solution of this issues is, first open your header.php with (NotePad++ Windows application, or any software that you use for programming PHP files) and move to menu (Encoder) and set (Encoder UTF-8 (sans BOM)).

I have the same problem before but I'm trying to fix it by deleting JS and CSS files and the problem still not fixed.

like image 1
Driss Baidou Avatar answered Nov 08 '22 20:11

Driss Baidou