All my <head> content is output / output to <body>

So this is my first post! I just created an account, but I always check here to solve my problems. I found others with the same problem, but the solutions did not work for me.

So, I have in the .PHP file all the content correctly placed in the head tag, but for some reason it is included in the body tag, leaving my first empty. And that adds a weird "

"(text space) at 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> 
+4
source share
4 answers

This is most likely caused by an error representing some text content in the head area.

It is very difficult to determine where PHP is generated instead of PHP, but the validator must pick it up.

+3
source

A simple solution

  • Open the file containing the file with Notepad ++
  • Click on the encoding, select Encode in UTF-8 without specification This fixes the problem.
+4
source

A simple solution to these problems: first open your header.php (NotePad ++ Windows application or any software that you use to program PHP files), and go to the (Encoder) menu and install (Encoder UTF-8 (sans BOM)) .

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

+1
source

(Sent on behalf of OP.)

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

+1
source

Source: https://habr.com/ru/post/1433151/


All Articles