Skip to main content

Last updated: March 13, 2026

How to Create CSS Pagination (7 Styles)

The complete guide to building beautiful, accessible pagination with pure CSS. From minimal to fully-featured designs with live demos and copy-paste code.

Building Pagination the Right Way

Good pagination helps users navigate through large sets of content. It should be visually clear, accessible to all users, and responsive across devices. Here are the key elements of well-designed pagination:

Semantic HTML

Use <nav> with aria-label, <ul>/<li> for structure, and aria-current for active page.

Clear Visual States

Distinct styles for default, hover, active, and disabled states help users understand what's clickable and where they are.

Responsive Design

Adapt pagination for mobile by hiding page numbers or using a compact layout with just prev/next and page indicator.

Basic Pagination Structure

Before diving into styles, let's understand the proper HTML structure for accessible pagination.

Semantic HTML Template

Key Accessibility Features

  • +<nav> landmark for screen readers
  • +aria-label describes navigation purpose
  • +aria-current="page" marks current page
  • +Descriptive labels for prev/next buttons

Structure Elements

  • *<nav> - Navigation landmark
  • *<ul> - List container
  • *<li> - List items for each page
  • *<a> or <button> - Interactive elements

Style Comparison

Compare pagination styles to find the best fit for your design.

Minimal

Hover Effect:Yes
Active State:Yes
Responsive:-

Rounded

Hover Effect:Yes
Active State:Yes
Responsive:-

Outlined

Hover Effect:Yes
Active State:Yes
Responsive:-

Filled

Hover Effect:Yes
Active State:Yes
Responsive:-

With Dots

Hover Effect:Yes
Active State:Yes
Responsive:-

Responsive

Hover Effect:Yes
Active State:Yes
Responsive:Yes

First/Last

Hover Effect:Yes
Active State:Yes
Responsive:-
1

Minimal Clean Style

A simple, clean pagination with subtle hover effects. Perfect for minimalist designs and content-focused websites.

Live Preview

Clean, minimal designSubtle hover effectsActive state indicatorAccessible with aria-labels

HTML + CSS Code

2

Rounded Button Style

Pagination with rounded buttons and a filled active state. Great for modern, friendly interfaces.

Live Preview

Pill-shaped buttonsFilled active statePrev/Next with text labelsSmooth hover transitions

HTML + CSS Code

3

Outlined Border Style

A classic outlined pagination with borders. Works well for professional and corporate designs.

Live Preview

Connected border designRounded first/last itemsArrow icons in prev/nextProfessional appearance

HTML + CSS Code

4

Filled Solid Style

Bold pagination with solid colored buttons. Ideal for dark themes or when you want pagination to stand out.

Live Preview

Bold, solid colorsElevated active state with shadowHigh contrast designWorks great on dark backgrounds

HTML + CSS Code

5

With Truncation Dots

Pagination with ellipsis for large page counts. Shows first, last, and pages around current selection.

Live Preview

Ellipsis for large page countsShows first and last pagesContext pages around currentNon-clickable dot indicators

HTML + CSS Code

6

Responsive Mobile-Friendly

Responsive

Adapts to screen size by hiding page numbers on mobile and showing only prev/next navigation with current page indicator.

Live Preview

Adapts to screen sizePage numbers on desktopPage indicator on mobileAlways shows prev/next buttons

HTML + CSS Code

7

With First & Last Buttons

Complete pagination with buttons to jump to the first and last pages. Useful for long lists where users may want to quickly navigate to extremes.

Live Preview

Jump to first/last pagePrev/next navigationBordered button styleComplete navigation controls

HTML + CSS Code

Pro Tips for Pagination

1. Always Use Semantic HTML

Wrap pagination in a <nav> element with aria-label. This helps screen readers identify the navigation and its purpose.

<nav aria-label="Pagination">
  <!-- pagination content -->
</nav>

2. Mark the Current Page

Use aria-current="page" to indicate the current page for screen readers, in addition to visual styling.

<a href="#"
   aria-current="page"
   class="active">
  2
</a>

3. Use Flexbox for Layout

Flexbox makes pagination layouts easy to maintain and responsive. Use gap for consistent spacing between items.

.pagination {
  display: flex;
  list-style: none;
  gap: 8px;
}

4. Handle Disabled States

Disable prev/next buttons when on first/last page. Use aria-disabled="true" and appropriate styling.

.pagination a[aria-disabled] {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

Frequently Asked Questions

What is the best HTML structure for pagination?

Use a <nav> element with aria-label='Pagination' as the wrapper, containing an unordered list (<ul>) with list items (<li>) for each page link. Use <a> tags for clickable pages and <span> for non-clickable elements like ellipsis. Add aria-current='page' to the active page link for accessibility.

How do I make pagination accessible?

Use semantic HTML with <nav> and aria-label. Add aria-label to prev/next buttons describing their action. Mark the current page with aria-current='page'. Ensure sufficient color contrast (4.5:1 for text). Make all interactive elements keyboard focusable with visible focus states.

Should I use <a> tags or <button> elements for pagination?

Use <a> tags if clicking changes the URL (traditional page navigation). Use <button> elements for JavaScript-based pagination that updates content without changing the URL (like infinite scroll or SPA pagination). Both are accessible when implemented correctly.

How do I style the active/current page?

Add a distinct visual style using background color, text color, or border. Common approaches include: filled background with contrasting text, underline or bottom border, or bold text. Also add aria-current='page' for screen readers.

How should pagination work on mobile devices?

On mobile, consider hiding numbered pages and showing only prev/next buttons with a 'Page X of Y' indicator. This saves space while maintaining functionality. Use media queries to switch between desktop and mobile layouts.

When should I use ellipsis (...) in pagination?

Use ellipsis when you have many pages (typically 7+). Show the first page, last page, current page, and 1-2 pages on either side of current. Replace the gaps with ellipsis. This keeps pagination compact while allowing navigation to any page.