Closing Tag For Paragraphs When Using Lists?


#1

Hi y’all! :slightly_smiling_face: I am currently learning to make paragraphs and lists in HTML & CSS. I am wondering, when starting a list is it necessary to use a close tag at the end of a paragraph?

Or does the code automatically assume that the paragraph has been closed because of the list tag? :face_with_raised_eyebrow: Thanks in advance for your help!


#2

Most browsers running HTML5 will forgive missing endtags on paragraphs and list items.

<p>some text
<p>some text
<p>some text
<p>some text
<li>list item
<li>list item
<li>list item
<li>list item
<li><p>some text
<li><p>some text
<li><p>some text
<li><p>some text

But it is folly to trust every browser. Best practice is to close all elements with the expected endtag.


#3

Thank you! I’ll stick to best practices and add in an endtag to keep it safe. :rofl:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.