3

Since you can't put <h2> tags and lists and such inside <p> tags. How to go about creating articles with <h2> tags and lists. Can I replace the <p> tag with a <div>? Or just leave out the <p> tag altogether?

Article example 1: ( No H tags )

<article>
<header>
  <img src="">
  <h1></h1>
  <p></p>
</header>
<p>
  <span style="width:100%;display:block;"><strong>hf</strong></span>
  <span style="width:100%;display:block;"><strong>fhfg</strong></span>
</p>
</article>

Article example 2: ( With H tags )

<article>
<header>
<img src="">
<h1></h1>
<p></p>
</header>
<p>
  <span style="width:100%;display:block;">ghjghj</span>
  <br>
  <span style="width:100%;display:block;">ghjghj</span>
</p>
<h2>ghjghjghjhhgjg</h2>
<span style="width:100%;display:block;">ghg</span>
<p></p>

As soon as the <h2> tag is introduced, the <p> tag gets automatically closed and the <h2> tag, and any content that follows will be placed outside the <p> tag.

Is the second example bad for SEO? And if so, would using a <div> tag in place of the <p> tags in example one be any better?

2 Answers 2

3

A <p> tag is specifically for a paragraph. If you are creating a section of a page, use a container tag, such as <article>, <div>, or <section>.

And, FYI, you can put whatever you want in a <p> and the browser will probably not have any problem with it. It's not good practice, it can lead to some unexpected behaviour, and it won't pass validation, but you can do it.

10
  • I'm using the article tag like the same way w3 school show you in their samantics tutorials. So article, header /header, p /p, /article.
    – D M
    Nov 11, 2019 at 17:51
  • The you can include <p>, <h2>, and <li> inside them, no problem. Nov 11, 2019 at 17:53
  • No you can't. The browser will close the p tag as soon as it sees the h tag
    – D M
    Nov 11, 2019 at 17:55
  • 2
    I think you may be missing some of the fundamentals of page structure. Have a look at the answer @closetnoc posted. It might help you more. Nov 11, 2019 at 18:08
  • 1
    The browser may not have a problem with it but you are relying on the browser to guess at your intentions and that is never a good thing.
    – Rob
    Nov 12, 2019 at 13:14
3

Think of writing a paper. Your paper would be one topic with subtopics. You would have headers and paragraphs. Headers define a subtopic of the papers topic and precede the paragraphs that cover the subtopic. You would have more than one subtopic in logical order to make your point. In effect, the headers are your topic outline.

This is how headers and paragraphs should be used.

That said, there is nothing that stops you from using a list or header within a paragraph. I would recommend avoiding it.

<h2>How does Price Signaling work?</h2>

<p>Price Signaling is a marketing method to reflect quality of the product being offered.</p>

<ul>
<li>People make judgments of the quality of the product based upon price.</li>
<li>People will chose the quality of the product that makes sense for their purpose based upon the price.</li>
<li>People will often not chose the lowest or highest priced product.</li>
<li>People will often chose the highest priced product when they are looking for a high quality product.</li>
</ul>

<p>Marketers will price their product toward the customer they desire.</p>

While this is a fairly standard example, if you need to style the list, for example, you may want to use other tags such as <strong> or <bold> or use your cascading style sheet (CSS) for style. Do not use header tags for style if that is what you are doing.

As far as the <article> tag is concerned, you would use this to "wrap" your entire content to send a signal to the search engines.

4
  • Detailed answer thank you. Your snippet is close to what I have however I have no real way of inserting a second set of p tags. I'm using quill.js to create article and the resulting code. If I were to use your snippet for example, would it be bad for SEO to leave out the second set of p tags?
    – D M
    Nov 11, 2019 at 18:14
  • @DM I do not know quill.js necessarily, however, I went to quilljs.com/playground and clicked the HTML button and inserted the code above between the container tags in the left panel. This worked for me. Is this the quilljs you are using?? I am leaving soon and will be back a few hours later. My brother and I are going to an early dinner for vets. Cheers!!
    – closetnoc
    Nov 11, 2019 at 18:39
  • Thanks for your efforts. That is the quill I'm using however it's the code after the fact I'm looking at. I'll jump on the computer soon and I'll be able to show you the code and explain myself a bit better. In the mean time, enjoy your meal and thanks again for your help.
    – D M
    Nov 11, 2019 at 18:46
  • I've updated my question and added snippets
    – D M
    Nov 12, 2019 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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