An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
If you are including a simple, relatively short list of three to five items within a paragraph —also known as a series—the proper formatting is to: (a) precede the list with a comma, (b) label each item with a lowercase letter enclosed in parentheses, and (c) separate each item with commas or semicolons.
<ul>: The Unordered List element. The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.
There are three types of lists in HTML: Unordered list or Bulleted list (ul) Ordered list or Numbered list (ol) Description list or Definition list (dl)
According to the HTML 5 specification, a paragraph may contain phrasing content, which still does not include other grouping elements:
http://www.w3.org/TR/html5/grouping-content.html#the-p-element
According to the HTML 4.01 specification, a paragraph may only contain inline elements:
http://www.w3.org/TR/html401/struct/text.html#h-9.3.1
9.3.1 Paragraphs: the P element
<!ELEMENT P - O (%inline;)* -- paragraph -->
<!ATTLIST P
%attrs; -- %coreattrs, %i18n, %events --
>
The correct markup in this case is to close your paragraph before starting the list.
Alternatively, you can use another tag other than paragraph (like <div>
) which is not processed in this way.
<div>
<ul> ... </ul>
</div>
I just had this issue and did not want to enclose it in a DIV since I was using P for the rest of that page and all pages. Instead I styled SPANs to behave like LIs.
SPAN.li {display: list-item; margin-left: 2em}
<P>These issues are currently on my mind
<SPAN class=li>My hat</SPAN>
<SPAN class=li>Global warming</SPAN>
<SPAN class=li>Global cooling</SPAN>
<SPAN class=li>Global terrorism</SPAN>
<SPAN class=li>Global narrow-mindedness</SPAN></P>
Lists aren't allowed in paragraphs - there's no way to do it, it's semantically impossible.
If you want the list to inherit styles from the paragraph, just add the UL element to the same CSS styles as your P elements:
eg:
p, ul { font-size: 12px; }
or better yet, encase both elements in something logical (section, article, div).
You've got to ask yourself why you want the list inside the paragraph. If it's because you want them styled the same, then you want them both in the same containing element, eg:
<article>
<p>Paragraph of text</p>
<ul>
<li>List</li>
</ul>
<p>Next paragraph</p>
</article>
and then style the article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With