A list group item can hold more than a single line of text. Give each item a heading, a paragraph and a line of small print and you have a compact list of articles, messages or search results.
Bootstrap 3 had two classes for this, .list-group-item-heading and .list-group-item-text. Both were removed in Bootstrap 4; spacing and flex utilities do the same job now and give more control.
Only the stylesheet is needed: https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css.
Example
<div class="list-group">
<a href="/what-is-html/" class="list-group-item list-group-item-action active" aria-current="true">
<div class="d-flex w-100 justify-content-between">
<h3 class="h5 mb-1">What is HTML?</h3>
<small>3 days ago</small>
</div>
<p class="mb-1">HTML (HyperText Markup Language) is the standard markup language for web pages.</p>
<small>Basics</small>
</a>
<a href="/what-is-css/" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="h5 mb-1">What is CSS?</h3>
<small class="text-body-secondary">1 week ago</small>
</div>
<p class="mb-1">Cascading Style Sheets (CSS) describe how a document written in a markup language is presented.</p>
<small class="text-body-secondary">Basics</small>
</a>
<a href="/what-is-bootstrap/" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="h5 mb-1">What is Bootstrap?</h3>
<small class="text-body-secondary">2 weeks ago</small>
</div>
<p class="mb-1">Bootstrap is an open source toolkit for building responsive websites with HTML, CSS and JavaScript.</p>
<small class="text-body-secondary">Frameworks</small>
</a>
</div>
How the layout works
The top line of each item is a flex row. d-flex w-100 justify-content-between puts the heading on the left and the date on the right. A long heading wraps inside its own space while the date stays pinned to the right edge.
mb-1 on the heading and paragraph replaces the old -heading and -text classes. Headings and paragraphs come with a bottom margin from Reboot, which is far too much inside a list item; mb-1 cuts it to 0.25rem.
The secondary text uses .text-body-secondary, which Bootstrap 5.3 introduced to replace .text-muted. It adapts to dark mode, and .text-muted is deprecated. The active item leaves it off because muted gray on the blue active background is hard to read; the item’s own white text color applies instead.
Choosing the heading level
The original example used <h4> because it looked the right size. Pick the heading level from the structure of the page instead: if the list sits under an <h2>, its items are <h3>. Then set the visual size with a class such as .h5, as above. Screen reader users often move through a page by headings, and skipped levels make that harder.
Block content inside a link
Wrapping a heading and paragraphs in an <a> is valid HTML5, and it makes the whole item clickable, which is what users expect. The cost is that a screen reader reads the entire content as the link text. For short items like these that is fine. If each item holds a long description, put the link on the heading only and make it cover the item with .stretched-link:
<div class="list-group">
<div class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="h5 mb-1"><a href="/what-is-html/" class="stretched-link text-decoration-none">What is HTML?</a></h3>
<small class="text-body-secondary">3 days ago</small>
</div>
<p class="mb-1">HTML (HyperText Markup Language) is the standard markup language for web pages.</p>
</div>
</div>
.stretched-link adds a pseudo-element that covers the nearest positioned ancestor. List group items are position: relative, so a click anywhere in the item follows the link, while the link text announced to screen readers stays short.
Rendering the list in ASP.NET Core
If the items come from a database, the Razor loop is straightforward:
<div class="list-group">
@foreach (var post in Model.Posts)
{
<a href="@post.Url" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="h5 mb-1">@post.Title</h3>
<small class="text-body-secondary">@post.Published.ToString("d MMM yyyy")</small>
</div>
<p class="mb-1">@post.Summary</p>
</a>
}
</div>
Razor HTML-encodes @post.Title and @post.Summary, so text from users cannot inject markup. The date format follows the current culture’s month names, so set the request culture if the site is multilingual.