p tag in h1 for seo

2019-02-19 12:32发布

I was wondering if using <p> tags nested in a <h1> tag would 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.

8条回答
戒情不戒烟
2楼-- · 2019-02-19 13:12

This is not valid HTML (5).

The specification says that the h1, ... h6 elements expect Phrasing content (see here). But this doesn't include the p tag (see here).

this would make my life a bit easier, dealing with dynamic pagetitles..

I don't really understand you. For subtitles, I would recommend using h2 or h3 - if necessary.

查看更多
Animai°情兽
3楼-- · 2019-02-19 13:16

This is what you want my friend:

<h1>
    My Question & Answer Page<br>
    <span style="font-size: 22px">I hope these answers help you!</span>
</h1>

My <h1> tag (all my 'h' tags actually) font size is set by CSS.

I'm sorry, I forget where I got that from, but it was a credible SEO company and I have used this for awhile now with no discernible adverse effects.

查看更多
做自己的国王
4楼-- · 2019-02-19 13:18

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).

查看更多
ゆ 、 Hurt°
5楼-- · 2019-02-19 13:24

what you are trying to achieve is just a line break, maybe using <br /> will be more appropriate since you are not dealing with paragraphs.

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

But I guess using <h1> and <h2> for example will be more appropriate to highlight the difference between the title and subtitle.

查看更多
Lonely孤独者°
6楼-- · 2019-02-19 13:27

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, why not use a dynamic language such as PHP/Python/Rails instead of static HTML?

查看更多
看我几分像从前
7楼-- · 2019-02-19 13:30

H1 tag really only takes a few words, and Google has stated that they count the first instance on it in SEO, so probably this approach will not give you any benefit. If might be even negative since its kind of "overdoing it" and too much of this technique may trigger some spam signal in Google which might be bad for your site actually.

Best is this:

<h1>Text</h1>
<p>
<h2>text</h2>
</p>
<p>
<h2>text</h2>
</p>
<p>
<h2>text</h2>
</p>
查看更多
登录 后发表回答