Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  bybe Jun 11 '13 at 13:06
    
no, google does not care about this –  user1721135 Jun 12 '13 at 5:56

4 Answers 4

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.

share|improve this answer
1  
A p element can't have h1 as a parent - h1's permitted contents is the same as p: Phrasing elements. –  l0b0 Jun 11 '13 at 11:47
    
Stated in the following W3C link for the p element: "Permitted parent elements: Any element that can contain flow elements" w3.org/TR/html-markup/p.html Stated in the following W3C link for Flow elements: "7.1 Flow elements: phrasing elements or ...h1": w3.org/TR/html-markup/common-models.html#common.elem.flow –  dan Jun 11 '13 at 12:25
1  
@dan That says h1 is a flow element, not that it 'can contain' them. Also w3.org/TR/html-markup/h1.html#h1 "Permitted contents Phrasing content" –  Random832 Jun 11 '13 at 12:35
1  
h1 as a parent to p is really extraneous to the question, so I'll just edit it out to end the debate. –  dan Jun 11 '13 at 12:43

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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