Blank line at top of HTML for WordPress
October 29, 2011 | Category: Tutorials | Tags: WordPress | Leave A Comment
Ever notice a blank line at the top of your html for WordPress? Wonder why it’s there? Let’s find out!
This is what I see at the top of my html code:

The blank line is appearing because one or more of my files has a blank line either before or after the beginning or ending php tags. But which files? That’s the hard part, finding which files are the problem. It’s usually best to start with your theme’s template files.
Go through each file and make sure that you don’t see the following:
1 2 3 4 | <?php some code here... ?> |
Notice the space on line 1 before the opening php tag? That’s one example of where the blank line comes from. Another example is if the blank line appears after the ending php tag. And that was my issue! It was happening on all of my page templates. Here’s an example:
1 2 3 4 5 6 7 | <?php /* Template Name: Blog */ ?> <?php get_header(); ?> |
Notice the space on line 6 after the ending php tag? That’s the problem. As soon as I removed it, no more blank line at the top of my html code!
Review your template files and make sure you didn’t make the same mistake!
Did you like this?
Subscribe to our
RSS Feed, join us on
Facebook, follow us on
Twitter or simply recommend us to friends!
You might also be interested in:
Would you like to personalize the administrative a...
Recently, I needed a way for a client to define an...
Tired of changing the copyright date in the footer...



