CSS Pagination
Rounded pagination buttons with a clear current page and ellipsis.
HTML
<nav class="pagination" aria-label="Pagination">
<a href="#" aria-label="Previous page">‹</a>
<a href="#">1</a>
<a href="#" aria-current="page">2</a>
<span>…</span>
<a href="#">9</a>
<a href="#" aria-label="Next page">›</a>
</nav>
CSS
.pagination {
display: flex;
gap: 6px;
font: 600 14px system-ui, sans-serif;
}
.pagination a,
.pagination span {
display: grid;
place-items: center;
box-sizing: border-box;
min-width: 36px;
height: 36px;
padding: 0 6px;
border-radius: 10px;
color: #374151;
text-decoration: none;
}
.pagination a {
border: 1px solid #e5e7eb;
background: #fff;
transition: border-color 0.15s ease;
}
.pagination a:hover {
border-color: #111;
}
.pagination [aria-current="page"] {
border-color: #111;
background: #111;
color: #fff;
}
.pagination span {
color: #9ca3af;
}
About this CSS Pagination
This CSS Pagination is 38 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, CSS Grid and Flexbox. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#374151#e5e7eb#fff#111#9ca3af
How to use this pagination
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.paginationclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.