Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Unordered list and Paragraph

Is it OK if I put unordered or ordered list inside a paragraph element?

<p>Movie Reviews: 
    <ul>
        <li><a href="#">Empire</a></li>
        <li><a href="#">Metacritic</a></li>
        <li><a href="#">Rotten Tomatoes</a></li>
        <li><a href="#">Variety</a></li>
    </ul>
</p>

6 Answers

James Barnett
James Barnett
39,199 Points

I just took a look at the code you posted. A better choice than a <p> would be a header element and the `<ul>. The level of header of course depends on where it comes in the document hierarchy.

<h2>Movie Reviews</h2>
<ul>
   <li><a href="#">Empire</a></li>
   <li><a href="#">Metacritic</a></li>
   <li><a href="#">Rotten Tomatoes</a></li>
   <li><a href="#">Variety</a></li>
</ul>

Technically, yes, but it's not best practice. All of your paragraph styles will then automatically apply to your lists. That includes spacing (margin, padding, line-height, etc), which is usually not a good idea since lists should have slightly different spacing from paragraph elements. Of course, setting explicit spacing for lists so that it overrides the paragraph spacing is a trivial step, but it's not the best way to go about it.

Again, this is more of a best practice than a rule. Your lists will still work, but it's not semantic.

James Barnett
James Barnett
39,199 Points

It depends ... remember your goal is to write semantic HTML. So if it's a sentence or a collection of sentences then mark it up as a <p> however if it's not maybe you want to use a <div> instead. Paste in your code and we can give you a better idea with some more context.

<p>Movie Reviews: <ul> <li><a href="#">Empire</a></li> <li><a href="#">Metacritic</a></li> <li><a href="#">Rotten Tomatoes</a></li> <li><a href="#">Variety</a></li> </ul> </p>

Hayder Al-Bayaty
Hayder Al-Bayaty
3,662 Points

it's possible but it depends on your code

Yes! It's basically the developers choice of how to code their website!

Hayder Al-Bayaty
Hayder Al-Bayaty
3,662 Points

it's totally fine you can simplely put them anywhere you like