lara336223's avatar

Lists of a feed, Styling

Hello, I was just wondering what your thoughts are on a feed of posts :~/ Should I Style them in Lists of or put them into Type thing ? What do you think would look best ? Thank-You Sid

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Great question! When displaying a feed of posts, you have a couple of common semantic HTML options: using a list (<ul> or <ol>) or using a container like <div>. Here are some considerations:

1. Using Lists (<ul> or <ol>)

If your feed is a collection of similar items (like posts, comments, or notifications), using a list is semantically correct. This helps with accessibility and gives more meaning to your markup.

Example:

<ul class="feed">
    <li class="feed-item">
        <h2>Post Title</h2>
        <p>Post content...</p>
    </li>
    <li class="feed-item">
        <h2>Another Post</h2>
        <p>More content...</p>
    </li>
</ul>

2. Using <div> Containers

If you need more flexibility or your feed items are complex and not just a simple list, using <div>s is also common. This is especially true if you're building a card-style layout.

Example:

<div class="feed">
    <div class="feed-item">
        <h2>Post Title</h2>
        <p>Post content...</p>
    </div>
    <div class="feed-item">
        <h2>Another Post</h2>
        <p>More content...</p>
    </div>
</div>

Styling

You can style both approaches similarly with CSS. For example, to remove default list styles:

.feed {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feed-item {
    border-bottom: 1px solid #eee;
    padding: 16px 0;
}

Recommendation

  • Use a list (<ul>) if your feed is a straightforward list of similar items.
  • Use <div>s if you want more flexibility or your feed items are more complex.

Both are valid, but for accessibility and semantics, a list is often preferred for feeds.

Let me know if you need help with specific CSS or layout ideas!

lara336223's avatar

Thank-you ! Should I have them inside a Container ? Or just let them run within the complete background ? Thank-You Sid

Please or to participate in this conversation.