8

Is it okay (SEO-wise) to construct the following line as such:

<p>These are the best <h1> Cheap Widgets </h1> ever. </p>

Wondering if this looks too unnatural for search engines?

3
  • You should consider H as a header, headers don't belong within the text otherwise they are not considered headers, this principle apples in things like magazines and books. If you want to have styling on things within a p you should opt to use a span tag. Commented Jun 11, 2013 at 13:06
  • no, google does not care about this Commented Jun 12, 2013 at 5:56
  • Instead of doing <h1>, what about using <b> or a Span with css to make it stand out, I know its 9+ years but in case anyone else comes across this answer, thought I'd add my advice instead. Commented Dec 19, 2022 at 9:56

4 Answers 4

26

According to the W3C, the P element can only contain other elements as listed here: Phrasing Elements.

Therefore, that is syntactically incorrect and may result in a browser error (check Firefox's console). It's recommended to validate your HTML code before submitting to search engines, so I'd suggest avoiding code that may produce errors or looks unnatural.

0
6

You cannot enclose h1 in p. It’s not just a matter of HTML rules; it’s also how browsers and search engines process the markup. Your example will be parsed as if it were

<p>These are the best </p><h1> Cheap Widgets </h1> ever. </p>

That is, one p element, followed by one h1 element, followed by just text not wrapped in an element, and then the syntactically incorrect and unexpected eng tag </p>, which will be ignored. This also affects styling. E.g., if you set p { font-family: Cambria }, it will affect the text “These are the best” only.

There’s really not much point in such trickery. People who develop search engines are generally smarter than people who try to fool them, though admittedly some tricks may work for some time.

3

There are definitely other reasons to do that (as mentioned in the other replies here), but it won't negatively affect your site's "SEO" compared to using the same text within a h1 outside of the p. FWIW just randomly placing keywords from your site within h1 elements isn't going to impress any modern search engines, it really makes sense to use them in a semantically correct way.

3

Additionally: It will, because Google structures information through headlines (generally through semantic markup, because it has no other means to do this). Therefore, you mess up the structure of your document by nesting a h1 in a p. Otherwise, you also distract people with screenreaders. And: what exactly is it supposed to mean, having a h1 by itself in a p? The headline has absolutely no context, and you have your document root headline somewhere in the middle of nowhere.

Solution, if you really don't like the h1 anywhere else: <h1 style="display: none"></h1> although this has other negative implications for your SEO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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