title: Wordpress Loop Creating Blank Space at Start of Page Loop
body: <p>On my single page blog posts, wordpress is creating this random empty (what I believe to be a) div. Could it possibly be the way I made my post loop? Not sure why this behavior is happening. If someone wants a link to see it in person, just comment. I am building the theme on my local machine, but I could put it on a live site if need be.</p>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php /* Template Name: Single Blog Page */ ?&gt;
  
  &lt;?php get_header(); ?&gt;
  
  &lt;div id="page-content"&gt;
  
  &lt;?php
  
  if( have_posts() ):
      while( have_posts() ): the_post(); ?&gt;
  
  
  &lt;div class="single-post"&gt;
      &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
      &lt;small&gt;Posted On: &lt;?php the_time( 'F j, Y' ); ?&gt; in &lt;?php the_category(); ?&gt;&lt;/small&gt;
      &lt;p&gt;&lt;?php the_content(); ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;hr&gt;
  
  &lt;/div&gt;
  
      &lt;?php endwhile;
  
  endif;
  
  ?&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.single-post {
      padding: 1em;
      border: 0.1em solid black;
  }
  </code></pre>
  
  <p>Rendered HTML:
  
      </p>
  
  <pre><code>    &lt;!-- Links --&gt;
      &lt;link rel="stylesheet" type="text/css" href="http://localhost:8888/wp-content/themes/ericshio/style.css" /&gt;
      &lt;link rel="shortcut icon" href="" /&gt;
  
      &lt;!-- Meta --&gt;
  
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"&gt;
  
      &lt;!-- Title --&gt;
  
      &lt;title&gt;Eric Shio&lt;/title&gt;
  
      &lt;!-- WP Head --&gt;
  
          &lt;meta name='robots' content='noindex,follow' /&gt;
  &lt;link rel="alternate" type="application/rss+xml" title="Eric Shio     &amp;raquo; Test Comments Feed"     href="http://localhost:8888/2016/08/04/test/feed/" /&gt;
      &lt;script type="text/javascript"&gt;
          window._wpemojiSettings =          {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/localhost:8888\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.5.3"}};
          !function(a,b,c){function d(a){var     c,d,e,f=b.createElement("canvas"),g=f.getContext&amp;&amp;f.getContext("2d"),h=Stri     ng.fromCharCode;if(!g||!g.fillText)return!1;switch(g.textBaseline="top",g.f    ont="600 32px Arial",a){case"flag":return     g.fillText(h(55356,56806,55356,56826),0,0),f.toDataURL().length&gt;3e3;case"di     versity":return   g.fillText(h(55356,57221),0,0),c=g.getImageData(16,16,1,1).data,d=c[0]+","+   c[1]+","+c[2]+","+c[3],g.fillText(h(55356,57221,55356,57343),0,0),c=g.getIm  ageData(16,16,1,1).data,e=c[0]+","+c[1]+","+c[2]+","+c[3],d!==e;case"simple":return g.fillText(h(55357,56835),0,0),0!==g.getImageData(16,16,1,1).data[0];case"unicode8":return g.fillText(h(55356,57135),0,0),0!==g.getImageData(16,16,1,1).data[0]}return!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i;for(i=Array("simple","flag","unicode8","diversity"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h&lt;i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&amp;&amp;c.supports[i[h]],"flag"!==i[h]&amp;&amp;(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&amp;&amp;c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&amp;&amp;!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&amp;&amp;c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&amp;&amp;f.twemoji&amp;&amp;(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
      &lt;/script&gt;
      &lt;style type="text/css"&gt;
  img.wp-smiley,
  img.emoji {
  display: inline !important;
  border: none !important;
  box-shadow: none !important;
  height: 1em !important;
  width: 1em !important;
  margin: 0 .07em !important;
  vertical-align: -0.1em !important;
  background: none !important;
  padding: 0 !important;
  }
     &lt;/style&gt;
       &lt;link rel='stylesheet' id='open-sans-css'     href='https://fonts.googleapis.com/css? family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&amp;#038;subset=latin%2Clatin-ext&amp;#038;ver=4.5.3' type='text/css' media='all' /&gt;
     &lt;link rel='stylesheet' id='dashicons-css'   href='http://localhost:8888/wp-includes/css/dashicons.min.css?ver=4.5.3'  type='text/css' media='all' /&gt;
    &lt;link rel='stylesheet' id='admin-bar-css'  href='http://localhost:8888/wp-includes/css/admin-bar.min.css?ver=4.5.3' type='text/css' media='all' /&gt;
   &lt;link rel='stylesheet' id='ericshiostyle-css'  href='http://localhost:8888/wp-content/themes/ericshio/style.css?ver=4.5.3' type='text/css' media='all' /&gt;
   &lt;link rel='https://api.w.org/' href='http://localhost:8888/wp-json/' /&gt;
   &lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://localhost:8888/xmlrpc.php?rsd" /&gt;
   &lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://localhost:8888/wp-includes/wlwmanifest.xml" /&gt; 
   &lt;link rel='prev' title='Hello world!' href='http://localhost:8888/2016/08/02/hello-world/' /&gt;
   &lt;meta name="generator" content="WordPress 4.5.3" /&gt;
   &lt;link rel="canonical" href="http://localhost:8888/2016/08/04/test/" /&gt;
  &lt;link rel='shortlink' href='http://localhost:8888/?p=48' /&gt;
  &lt;link rel="alternate" type="application/json+oembed" href="http://localhost:8888/wp-json/oembed/1.0/embed?url=http%3A%2F%2Flocalhost%3A8888%2F2016%2F08%2F04%2Ftest%2F" /&gt;
  &lt;link rel="alternate" type="text/xml+oembed" href="http://localhost:8888/wp-json/oembed/1.0/embed?url=http%3A%2F%2Flocalhost%3A8888%2F2016%2F08%2F04%2Ftest%2F&amp;#038;format=xml" /&gt;
  &lt;style type="text/css" media="print"&gt;#wpadminbar { display:none; }       &lt;/style&gt;
  &lt;style type="text/css" media="screen"&gt;
  html { margin-top: 32px !important; }
  * html body { margin-top: 32px !important; }
  @media screen and ( max-width: 782px ) {
      html { margin-top: 46px !important; }
      * html body { margin-top: 46px !important; }
  }
  &lt;/style&gt;
   &lt;/head&gt;
  
      &lt;!-- Body --&gt;
  
  &lt;body class="single single-post postid-48 single-format-standard logged-in admin-bar no-customize-support wp-custom-logo"&gt;
  
      &lt;!-- Site Header --&gt;
  &lt;header class="site-header"&gt;
    &lt;a href="http://localhost:8888/" class="custom-logo-link" rel="home" itemprop="url"&gt;&lt;img width="257" height="239" src="http://localhost:8888/wp-content/uploads/2016/08/TEXT-FILM-STRIP.png" class="site-branding" alt="TEXT FILM STRIP" itemprop="logo" /&gt;&lt;/a&gt;            &lt;div class="menu-main-navigation-container"&gt;&lt;ul id="menu-main-navigation" class="main-navigation"&gt;&lt;li id="menu-item-29" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-29"&gt;&lt;a href="http://localhost:8888/"&gt;Overview&lt;/a&gt;&lt;/li&gt;
  &lt;li id="menu-item-22" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-22"&gt;&lt;a href="http://localhost:8888/expeditions/"&gt;Expeditions&lt;/a&gt;
  &lt;ul class="sub-menu"&gt;
  &lt;li id="menu-item-20" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20"&gt;&lt;a href="http://localhost:8888/expeditions/vancouver/"&gt;Vancouver&lt;/a&gt;&lt;/li&gt;
  &lt;li id="menu-item-21" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-21"&gt;&lt;a href="http://localhost:8888/expeditions/seattle/"&gt;Seattle&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page current_page_parent menu-item-27"&gt;&lt;a href="http://localhost:8888/blog/"&gt;Blog&lt;/a&gt;&lt;/li&gt;
  &lt;li id="menu-item-33" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-33"&gt;&lt;a href="http://localhost:8888/about/"&gt;About&lt;/a&gt;    &lt;/li&gt;
   &lt;li id="menu-item-23" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-23"&gt;&lt;a href="http://localhost:8888/contact/"&gt;Contact&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;&lt;/div&gt;    &lt;/header&gt;
      &lt;!-- /Site Header --&gt;
  
  &lt;!-- Container --&gt;
  &lt;div class="container"&gt;
  
  &lt;!-- Site Content --&gt;
  
  
  &lt;div id="page-content"&gt;
  &lt;/div&gt;
  
  &lt;!-- /Site Content --&gt;
  
  &lt;/div&gt;
  
  &lt;!-- /Container --&gt;
  &lt;div id="page-content"&gt;
  
  
  
  &lt;div class="single-post"&gt;
      &lt;h3&gt;Test&lt;/h3&gt;
      &lt;small&gt;Posted On: August 4, 2016 in &lt;ul class="post-categories"&gt;
  &lt;li&gt;&lt;a href="http://localhost:8888/category/uncategorized/" rel="category tag"&gt;Uncategorized&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/small&gt;
      &lt;p&gt;&lt;p&gt;Stuff&lt;/p&gt;
  &lt;/p&gt;
  &lt;/div&gt;
  &lt;hr&gt;
  
  &lt;/div&gt;
  
  
  &lt;!-- Footer --&gt;
  
  &lt;footer class="site-footer"&gt;
  &lt;p&gt;&lt;a href="mailto:hello@ericshio.com"&gt;hello@ericshio.com&lt;/a&gt; &amp;copy; Eric Shiozaki&lt;/p&gt;
   &lt;div id="footer-sidebar" class="secondary"&gt;
   &lt;div id="footer-sidebar1"&gt;
   &lt;/div&gt;
   &lt;div id="footer-sidebar2"&gt;
   &lt;/div&gt;
   &lt;div id="footer-sidebar3"&gt;
   &lt;/div&gt;
   &lt;/div&gt;   
   &lt;/footer&gt;
   &lt;script type='text/javascript' src='http://localhost:8888/wp-includes/js/admin-bar.min.js?ver=4.5.3'&gt;&lt;/script&gt;
   &lt;script type='text/javascript' src='http://localhost:8888/wp-content/themes/ericshio/js/ericshio.js?ver=1.0.0'&gt;&lt;/script&gt;
    &lt;script type='text/javascript' src='http://localhost:8888/wp-includes/js/wp-embed.min.js?ver=4.5.3'&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      (function() {
          var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
  
          request = true;
  
          b[c] = b[c].replace( rcs, ' ' );
          b[c] += ( window.postMessage &amp;&amp; request ? ' ' : ' no-' ) + cs;
      }());
  &lt;/script&gt;
          &lt;div id="wpadminbar" class="nojq nojs"&gt;
                          &lt;a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"&gt;Skip to toolbar&lt;/a&gt;
                      &lt;div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="Toolbar" tabindex="0"&gt;
              &lt;ul id="wp-admin-bar-root-default" class="ab-top-menu"&gt;
      &lt;li id="wp-admin-bar-wp-logo" class="menupop"&gt;&lt;a class="ab-item"  aria-haspopup="true" href="http://localhost:8888/wp-admin/about.php"&gt;&lt;span class="ab-icon"&gt;&lt;/span&gt;&lt;span class="screen-reader-text"&gt;About WordPress&lt;/span&gt;&lt;/a&gt;&lt;div class="ab-sub-wrapper"&gt;&lt;ul id="wp-admin-bar-wp-logo-default" class="ab-submenu"&gt;
      &lt;li id="wp-admin-bar-about"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/about.php"&gt;About WordPress&lt;/a&gt;     &lt;/li&gt;&lt;/ul&gt;&lt;ul id="wp-admin-bar-wp-logo-external" class="ab-sub-secondary ab-submenu"&gt;
      &lt;li id="wp-admin-bar-wporg"&gt;&lt;a class="ab-item"  href="https://wordpress.org/"&gt;WordPress.org&lt;/a&gt;     &lt;/li&gt;
      &lt;li id="wp-admin-bar-documentation"&gt;&lt;a class="ab-item"  href="https://codex.wordpress.org/"&gt;Documentation&lt;/a&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-support-forums"&gt;&lt;a class="ab-item"  href="https://wordpress.org/support/"&gt;Support Forums&lt;/a&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-feedback"&gt;&lt;a class="ab-item"  href="https://wordpress.org/support/forum/requests-and-feedback"&gt;Feedback&lt;/a&gt;        &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-site-name" class="menupop"&gt;&lt;a class="ab-item"  aria-haspopup="true" href="http://localhost:8888/wp-admin/"&gt;Eric Shio&lt;/a&gt;&lt;div class="ab-sub-wrapper"&gt;&lt;ul id="wp-admin-bar-site-name-default" class="ab-submenu"&gt;
      &lt;li id="wp-admin-bar-dashboard"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/"&gt;Dashboard&lt;/a&gt;        &lt;/li&gt;&lt;/ul&gt;&lt;ul id="wp-admin-bar-appearance" class="ab-submenu"&gt;
      &lt;li id="wp-admin-bar-themes"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/themes.php"&gt;Themes&lt;/a&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-widgets"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/widgets.php"&gt;Widgets&lt;/a&gt;     &lt;/li&gt;
      &lt;li id="wp-admin-bar-menus"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/nav-menus.php"&gt;Menus&lt;/a&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-background" class="hide-if-customize"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/themes.php?page=custom-background"&gt;Background&lt;/a&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-header" class="hide-if-customize"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/themes.php?page=custom-header"&gt;Header&lt;/a&gt;       &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-customize" class="hide-if-no-customize"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/customize.php?url=http%3A%2F%2Flocalhost%3A8888%2F2016%2F08%2F04%2Ftest%2F"&gt;Customize&lt;/a&gt;     &lt;/li&gt;
      &lt;li id="wp-admin-bar-comments"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/edit-comments.php"&gt;&lt;span class="ab-icon"&gt;&lt;/span&gt;&lt;span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-0" aria-hidden="true"&gt;0&lt;/span&gt;&lt;span class="screen-reader-text"&gt;0 comments awaiting moderation&lt;/span&gt;&lt;/a&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-new-content" class="menupop"&gt;&lt;a class="ab-item"  aria-haspopup="true" href="http://localhost:8888/wp-admin/post-new.php"&gt;&lt;span class="ab-icon"&gt;&lt;/span&gt;&lt;span class="ab-label"&gt;New&lt;/span&gt;&lt;/a&gt;           
  
   &lt;div class="ab-sub-wrapper"&gt;&lt;ul id="wp-admin-bar-new-content-default" class="ab-submenu"&gt;
      &lt;li id="wp-admin-bar-new-post"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/post-new.php"&gt;Post&lt;/a&gt;      &lt;/li&gt;
      &lt;li id="wp-admin-bar-new-media"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/media-new.php"&gt;Media&lt;/a&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-new-page"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/post-new.php?post_type=page"&gt;Page&lt;/a&gt;         &lt;/li&gt;
      &lt;li id="wp-admin-bar-new-user"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/user-new.php"&gt;User&lt;/a&gt;      &lt;/li&gt;&lt;/ul&gt;    &lt;/div&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-edit"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/post.php?post=48&amp;#038;action=edit"&gt;Edit Post&lt;/a&gt;        &lt;/li&gt;&lt;/ul&gt;&lt;ul id="wp-admin-bar-top-secondary" class="ab-top-secondary ab-top-menu"&gt;
      &lt;li id="wp-admin-bar-search" class="admin-bar-search"&gt;&lt;div class="ab-item ab-empty-item" tabindex="-1"&gt;&lt;form action="http://localhost:8888/" method="get" id="adminbarsearch"&gt;&lt;input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" /&gt;&lt;label for="adminbar-search" class="screen-reader-text"&gt;Search&lt;/label&gt;&lt;input type="submit" class="adminbar-button" value="Search"/&gt;&lt;/form&gt;&lt;/div&gt;       &lt;/li&gt;
      &lt;li id="wp-admin-bar-my-account" class="menupop with-avatar"&gt;&lt;a class="ab-item"  aria-haspopup="true" href="http://localhost:8888/wp-admin/profile.php"&gt;Howdy, @eshiozaki&lt;img alt='' src='http://1.gravatar.com/avatar/dda9d12be8829bad13acdbde559319b0?s=26&amp;#038;d=mm&amp;#038;r=g' srcset='http://1.gravatar.com/avatar/dda9d12be8829bad13acdbde559319b0?s=52&amp;amp;d=mm&amp;amp;r=g 2x' class='avatar avatar-26 photo' height='26' width='26' /&gt;&lt;/a&gt;&lt;div class="ab-sub-wrapper"&gt;&lt;ul id="wp-admin-bar-user-actions" class="ab-submenu"&gt;
      &lt;li id="wp-admin-bar-user-info"&gt;&lt;a class="ab-item" tabindex="-1" href="http://localhost:8888/wp-admin/profile.php"&gt;&lt;img alt='' src='http://1.gravatar.com/avatar/dda9d12be8829bad13acdbde559319b0?s=64&amp;#038;d=mm&amp;#038;r=g' srcset='http://1.gravatar.com/avatar/dda9d12be8829bad13acdbde559319b0?s=128&amp;amp;d=mm&amp;amp;r=g 2x' class='avatar avatar-64 photo' height='64' width='64' /&gt;&lt;span class='display-name'&gt;@eshiozaki&lt;/span&gt;&lt;/a&gt;        &lt;/li&gt;
      &lt;li id="wp-admin-bar-edit-profile"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-admin/profile.php"&gt;Edit My Profile&lt;/a&gt;                 &lt;/li&gt;
      &lt;li id="wp-admin-bar-logout"&gt;&lt;a class="ab-item"  href="http://localhost:8888/wp-login.php?action=logout&amp;#038;_wpnonce=cc2d8b5dfd"&gt;Log Out&lt;/a&gt;       &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;             &lt;/li&gt;&lt;/ul&gt;         &lt;/div&gt;
                      &lt;a class="screen-reader-shortcut" href="http://localhost:8888/wp-login.php?action=logout&amp;#038;_wpnonce=cc2d8b5dfd"&gt;Log Out&lt;/a&gt;
                  &lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>