Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p tag in h1 for seo

Would using <p> tags nested in a <h1> tag be bad for SEO purposes?

<h1>
    <p>Some title</p>
    <p>Some subtitle</p>
</h1>

This would make my life a bit easier, dealing with dynamic page titles.

like image 348
dreagan Avatar asked Dec 09 '22 02:12

dreagan


2 Answers

Search engines may ignore p markup inside h1. Or they might dislike it, doing something nasty. In any case, there is nothing to be gained by using such markup. Instead, you can use

<h1>
some title<br>
<small>some subtitle</small>
</h1>

You can then tune the relative sizes by setting font-size on h1 small. You can also set padding-top on it, if you wish to have more spacing between the parts.

Search engines can be expected to treat the h1 element as just containing “some title some subtitle”. If this makes a long heading, they may discard part of it (near the end) or maybe just reduce the relative importance of the contents from the weight that a short heading would have.

In any case, you should expects words in headings have relative weight in SEO, relative to other contents on the page, not to the outside world (other web pages).

like image 148
Jukka K. Korpela Avatar answered Jan 03 '23 12:01

Jukka K. Korpela


I don't know about SEO, but your intended usage is not valid HTML and I would advise against using tags in such a manner.

If you need to work with dynamic page titles, use a dynamic language such as PHP, Python, or Ruby on Rails instead of static HTML.

like image 31
PenguinCoder Avatar answered Jan 03 '23 14:01

PenguinCoder