There are cases where nothing is printed inside the header element, and yet the header element is printed by itself (just the empty HTML). It should be wrapped — in the node.tpl.php file — in a conditional to prevent this.

 
  <?php if ($title_prefix || $title_suffix || $display_submitted || $unpublished || !$page && $title): ?>
    <header>
      <?php print render($title_prefix); ?>
      <?php if (!$page && $title): ?>
        <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
      <?php endif; ?>
      <?php print render($title_suffix); ?>
 
      <?php if ($display_submitted): ?>
        <p class="submitted">
          <?php print $user_picture; ?>
          <?php print $submitted; ?>
        </p>
      <?php endif; ?>
 
      <?php if ($unpublished): ?>
        <p class="unpublished"><?php print t('Unpublished'); ?></p>
      <?php endif; ?>
    </header>
  <?php endif; ?>

When does this happen? On a node page (where the title is printed outside the article tag, instead of in... where there's no title prefix or suffix (common), it's not unpublished, no user pict... and most of all, the submitted information is being withheld on a node.

So to replicate — make a content type. Do not display submit info. Create a node. Go to the node page. View source. You'll see empty <header></header>.

This: <?php if ($title_prefix || $title_suffix || $display_submitted || $unpublished || !$page && $title): ?> prevents that. Double check to make sure that conditional is well written.

Comments

patch?

According to the docs http://drupal.org/node/254940#title-prefix-suffix, we still want $title_prefix and $title_suffix even if there is no title displayed.

“All standard templates that potentially have a title ... should render these variables. It is important that the variables be rendered even if the title itself is not being displayed, since the variables might contain important data added by modules (for example, contextual links) associated with the template as a whole.”

So if there’s just those variables, would we still wrap the header element around them?

Component:PHP code» layout.css

So if there’s just those variables, would we still wrap the header element around them?

It depends on what a module stuffs into those variables. Core just adds contextual links, which I would say we don't want to wrap in <header> element. But there's no easy way to write a PHP conditional to make that kind of decision.

Let's just use what Jen suggested.

Title:If statement needed around <header> in node.tplAdd if statement around <header> in node.tpl
Component:layout.css» PHP/JS code
Status:Active» Fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.