Bootstrap 5 Pagination
When content is split over several pages — search results, blog archives, product lists — pagination links let the user jump between them. Bootstrap's pagination is a list of links: a <ul class="pagination"> with <li class="page-item"> items, each containing an <a class="page-link">.
Basic pagination
Wrap it in a <nav> with an aria-label so assistive technology knows it's a navigation landmark.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<nav aria-label="Search results pages">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>
</body>
</html>Active and disabled states
Mark the current page with .active (and aria-current="page"). Disable links that make no sense — "Previous" on page 1 — with .disabled. A disabled item is best rendered as a <span> so it can't be focused or clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<nav aria-label="Blog pages">
<ul class="pagination">
<li class="page-item disabled"><span class="page-link">«</span></li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item disabled"><span class="page-link">…</span></li>
<li class="page-item"><a class="page-link" href="#">12</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next"><span aria-hidden="true">»</span></a>
</li>
</ul>
</nav>
</body>
</html>When you use symbols like « and », add an aria-label to the link and hide the symbol with aria-hidden="true", so screen readers say "Next" instead of "right-pointing double angle quotation mark".
Sizes and alignment
.pagination-lg and .pagination-sm resize the whole control. The .pagination list is a flex container, so justify-content-center or justify-content-end aligns it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<nav aria-label="Large">
<ul class="pagination pagination-lg">
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
</ul>
</nav>
<nav aria-label="Small, centred">
<ul class="pagination pagination-sm justify-content-center">
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
</ul>
</nav>
<nav aria-label="Right aligned">
<ul class="pagination justify-content-end">
<li class="page-item"><a class="page-link" href="#">Older</a></li>
<li class="page-item"><a class="page-link" href="#">Newer</a></li>
</ul>
</nav>
</body>
</html>Interactive pagination
Pagination is just styled links — Bootstrap has no pagination JavaScript. Here a small script swaps the content and the active item.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="border rounded p-3 mb-3 fs-4 text-center" id="page">🍎 Page 1: apples</div>
<nav aria-label="Fruit pages">
<ul class="pagination justify-content-center" id="pager">
<li class="page-item active"><a class="page-link" href="#" data-page="1">1</a></li>
<li class="page-item"><a class="page-link" href="#" data-page="2">2</a></li>
<li class="page-item"><a class="page-link" href="#" data-page="3">3</a></li>
</ul>
</nav>
<script>
const pages = { 1: '🍎 Page 1: apples', 2: '🍌 Page 2: bananas', 3: '🍒 Page 3: cherries' };
document.getElementById('pager').addEventListener('click', (e) => {
const link = e.target.closest('.page-link');
if (!link) return;
e.preventDefault();
document.querySelectorAll('#pager .page-item').forEach((li) => li.classList.remove('active'));
link.parentElement.classList.add('active');
document.getElementById('page').textContent = pages[link.dataset.page];
console.log('showing page', link.dataset.page);
});
</script>
</body>
</html>Class reference
| Class | Purpose |
|---|---|
.pagination |
The <ul> container (flex) |
.page-item |
Each <li> |
.page-link |
The <a> or <span> inside |
.active (on .page-item) |
Current page |
.disabled (on .page-item) |
Non-clickable item |
.pagination-lg / .pagination-sm |
Size |
.justify-content-center / -end |
Alignment |
Tip: For a simple "Older / Newer" control on a blog, two buttons or two page items are enough. Show numbered pages only when users really need to jump to a specific page.
Test yourself
Which element should wrap a pagination list for accessibility?
- <div>
- <nav> with an aria-label
- <section>
- <footer>
Where does the .active class go?
- On the .page-link
- On the .page-item
- On the .pagination
- On the nav
How do you centre a pagination control?
- .text-center on the ul
- .justify-content-center on the .pagination
- .mx-auto on each item
- .pagination-center