r/HTML • • Sep 20 '26

Putting an unordered list inside a paragraph??

Why doesn't this work?? Like ik the specs prohibit it but why would they do that? there are valid reasons to want to do this. For example I have a list of long descriptions so to make it easier to read I wanted to use a vertical list. It would be very confusing to split the paragraph.

If anyone is in the same situation as me I think the best alternative is to use a span with css that makes it look like a list.

0 Upvotes

21 comments sorted by

16

u/DirtAndGrass Sep 20 '26

Because paragraphs don't have bullet points in them? Not in HTML, not in English, not in other languages that I know of. 

Paragraphs don't have extra whitespace, they are contiguous and continuous text. 

1

u/Ashk3000 Sep 24 '26

Its possible in English

1

u/Ashk3000 Sep 24 '26

This is a screenshot of the MLA handbook. The spacing does make it seem like its seperate, but i imagine it should be treated as one paragraph by a screen reader.

1

u/DirtAndGrass Sep 24 '26

There are no paragraphs inside of other paragraphs in your screenshot? 

0

u/Flashy-Guava9952 Sep 21 '26

Are bullet points that exotic?

3

u/DirtAndGrass Sep 21 '26

No, but inside a paragraph, yes, incorrect.

They are essentially their own paragraph 

1

u/Flashy-Guava9952 Sep 24 '26

Learn something new every day...

1

u/Flashy-Guava9952 Sep 24 '26

Can you put list items inside of paragraphs?

1

u/DirtAndGrass Sep 24 '26

Nope, they are themselves paragraphs, paragraphs cannot (grammatically) contain paragraphs 

14

u/notepad987 Sep 20 '26 edited Sep 22 '26

In standard HTML, placing an unordered list (<ul>) inside a paragraph (<p>) is invalid HTML.
Browsers will automatically close the <p> tag when they encounter a block-level element like <ul>.

Corrected to what OvenActive posted
Codepen workaround

8

u/nonchip Sep 20 '26

because that's a single line paragraph followed by a list. how do you even imagine that'd work?

7

u/SamIAre Sep 20 '26

How would you want a screenreader to interpret it? As an actual ordered list it would read as a paragraph fragment and then a separate list, even if you were able to embed the list in the paragraph.

Screenreaders announce lists, the number of items and let users navigate that list. To me, this seems more like a purely stylistic way to present just a normal sentence with what would otherwise be a comma-delineated list. So IMO, unless you want actual list behavior and just want bullets and line breaks, I would emulate a list in CSS without an actual unordered list element.

3

u/pfdemp Sep 20 '26

I wonder if OP is just concerned about how it looks with the space between the text and the list? This can be modified with some CSS.

2

u/OvenActive Expert Sep 22 '26

What you are trying to do:

<p>Slide 5 is a board game similar to Connect 4, but
    <ul>
        <li>there are 2 sides to put pieces in,</li>
        <li>pieces only move down the board when pushed,</li>
        <li>you must get 5 in a row or diagnal to win.</li>
    </ul>
</p>

What you want to do:

<p>Slide 5 is a board game similar to Connect 4, but</p>
<ul>
    <li>there are 2 sides to put pieces in,</li>
    <li>pieces only move down the board when pushed,</li>
    <li>you must get 5 in a row or diagonal to win.</li>
</ul>

1

u/notepad987 Sep 22 '26

Yep that is the correct way then you can add more paragraphs below the list.

<p> Slide 5 is a board game similar to Connect 4, but:</p>
    <ul class="inline-list">
      <li>there are 2 sides to put pieces in,</li>
      <li>pieces only move down the board when pushed,</li>
      <li>you must get 5 in a row or diagnal to win.</li>
    </ul>
   <p>Normally in standard HTML, placing an unordered list ul inside a paragraph p is invalid HTML. <br> Browsers will automatically close the p tag when they encounter a block-level element like ul. Above code is a workaround.</p>

2

u/lbunch1 Sep 20 '26

I get what you are saying semantically, but how do you envision it rendering without in a way "splitting" the paragraph?

If it bothers you that much, just use a div in place of the p tag I guess.

5

u/balldozerr Sep 20 '26

Actually don't use a div for this

4

u/lbunch1 Sep 20 '26

I mean yeah, stick to semantic tags. But if it doesn't want to split a paragraph to put a list in, then use something that allows for it.

But yeah the right answer is definitely just stick to the standard <p></p><ul></ul><p></p>

1

u/the-liquidian Sep 21 '26

You should probably use the original p tag with ul with css. If the gap is too large just live with it, it’s probably a good idea to have it.

1

u/LowLevelUser Sep 21 '26

Maybe finish the paragraph first, then throw the bullet points underneath it.