The 'p' tag in 'h1' for SEO [closed]
Asked Answered
E

8

2

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.

Elston answered 21/2, 2012 at 14:59 Comment(4)
possible duplicate of Can i have paragraph elements inside of a heading tag in HTML5 (p inside h1)Florineflorio
Judging techniques to improve SEO is off topicGould
I voted to close this question because it is not a programming question and it is off-topic on Stack Overflow. Non-programming questions about your website should be asked on Webmasters. In the future, please ask questions like this there.Overlie
Similar questions asked on a Webmasters: Do you need to place an 'h1' into a 'p' tag in order to style it so it won't hurt your SEO? and Will enclosing an <h1> element inside a <p> element affect SEO?Overlie
C
9

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

Cryptic answered 21/2, 2012 at 17:5 Comment(0)
D
2

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.

Dewhurst answered 21/2, 2012 at 15:5 Comment(0)
E
2

This is what you want:

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

Endways answered 2/2, 2013 at 20:55 Comment(0)
S
1

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.

Spoiler answered 21/2, 2012 at 15:3 Comment(1)
simply forgot it wasn't valid html.. -_- And as for not understanding me, please let me clarify: I just got this big existing project pushed unto me and they needed me to make it more SEO friendly. It's already using ColdFusion as server-side language and they have a very confusing styling setup, making me want to avoid going there as much as possible for now.. ^^' all the <h>'s are already in use, so I'll be going with <br />.Elston
F
0

If you want to use titles and subtitles, use h1, h2, etc. With that way the crawlers understands the hierarchy and the importance of your headlines.

Formyl answered 21/2, 2012 at 15:3 Comment(0)
S
0

You are trying to achieve 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.

Studdingsail answered 21/2, 2012 at 15:4 Comment(1)
How is that related to SEO?Wordsmith
C
0

I don't think it would be worse for SEO to include <p>aragraphs around the text but it isn't valid HTML so you shouldn't do it anyway.

It could be bad to have too long/spammy headings though if that's what you're asking.

Cephalopod answered 21/2, 2012 at 15:4 Comment(1)
Re "I don't think it would be worse for SEO": Google may punish incorrect HTML. E.g., from Does Valid HTML Affect SEO?: "Overly malformed code can cause the crawler to choke and depart early."Wordsmith
O
0

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

It might be even negative since it’s 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.

The best is this:

<h1>Text</h1>
<p>
<h2>text</h2>
</p>
<p>
<h2>text</h2>
</p>
<p>
<h2>text</h2>
</p>
Ogg answered 21/2, 2012 at 15:6 Comment(2)
This actually doesn't seem to be valid HTML. The W3C Validator reports end tag for element "P" which is not open, regardless of whether the doctype is set to HTML 5 or HTML 4.01 Transitional. I think <h1>, <h2> etc. cannot be nested inside <p>.Veteran
Why is it the best? Please respond by editing your answer, not here in comments (without "Edit:", "Update:", or similar - the answer should appear as if it was written today).Wordsmith

© 2022 - 2024 — McMap. All rights reserved.