2

Is this bad for SEO? The designers came up with it. Basically there is an icon next to each Header Text. So for each page and the respective header there is an icon associated with the page.

Markup:

<h1>
<span class="span"><img class="spanImg" src="../img/pageIcon.png"></span>
<span class="text">Header Title Text Here</span>
</h1>

CSS:

.span, .text {
vertical-align: middle;
display: table-cell;
color: #CCC;
}

.spanImg {
width: 40px;
height: 40px;
margin-right: 8px;
}

The header tags have some CSS mark up as well.

Thanks just curious if this is bad practice or not for SEO header tags.

0

While this code may not cause harm, it is highly recommended that you do not put images or anything other than text into a hearer tag. The reason for this is simple. The header tag is an extremely important semantic clue for search engines. It is a content tag and not a format tag. For this reason, header tags should be textual content only. There is, for example, no reason to do this since you can have the image before the header tag.

1

Technically images are not headers and headers are designed for text based content, just a like a chapter in a book, however with this said, Google and other search engines will not give a ducking duck!

However, it seems that you would use this method because your using some code that you got elsewhere, or because you can't be bothered to adapt your current code. If you want to vertical-align then use a upper container to do so, for example:

<div class="example-container>
    <img src="example.jpg" alt="example">
    <h1>Example</h1>
</div>

Then use the vertical-align on the parent container, not the childs. You can use:

.example-container {
    vertical-align: middle;
    display: table-cell;
    color: #CCC;
}

.example-container img {
    margin: 0 auto;
    display: block;
}    

.example-container h1 {
    text-align: center;
}

Also, don't forget to make use of the ALT tag, as your example code does not, and that can help your SEO.

1
  • Not sure why you and I got down-votes for these answers. It seems rather silly considering that both you and I are correct and that, in fact, your answer is more detailed and very good. I can at least do something about yours anyway! Cheers!! – closetnoc Dec 7 '15 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.