• On line 63 in header.php in the Coraline theme, there is a if statement checking the current page to make the header title <div> instead of <h1> if it’s not on the home page

    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    <<?php echo $heading_tag; ?> id="site-title">

    I’m just wondering if anyone knows the purpose/idea of this line as it’s clearly makes the theme inconsistent with it’s self.

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • alledgedly, seo reasons.

    the Twenty Ten default theme does the same.

    It’s invalid to have two h1 tags…when you’re on the front or home page, you’ll have multiple titles, which are given h2 tags. h1 will probably be your blog site name. When you go to a single page, it changes the site name to a regular div (I change mine to an h2). This way Search engines & readers are able to distinguish the title of your post from the other headings in your post.

    It’s invalid to have two h1 tags

    No – it’s not! Whether it’s good design practice is another thing entirely and will probably be affected by the context of the h1 in the overall document/header structure.

    If you validate your code with the W3C here, and with 2 h1 tags, it will tell you it’s invalid markup.

    http://validator.w3.org/

    I’m not going to argue the validity of html.

    Care to provide an example?

    I would but every website I visit only uses one h1 tag per page…and for good reason, it’s the right way to do it.

    I agree that this is common practice and usually for good reason. But it’s also arguable that it’s bad for SEO if a site uses h1 for the site name on every page and h2 for, say, a single post title. Logically, both headers describe very different resources (site v. document) and could, therefore, be used independently of one another. It’s also arguable that the site name merely replicates the meta-title content and therefore does not merit a higher header placement than the page title.

    Ether way, two h1 tags on an HTML or XHTML page will not invalidate it against the W3C specs. All that the specs do recommend is that headers should be used in a logical and hierarchical manner to convey the document’s structure.

    I’m not mandating a page full of h1 headers. Merely pointing out that, in some contexts, two h1 headers in a page would be valid and could well be semantically correct.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘h1 vs div in header.php in Coraline’ is closed to new replies.