CSS Pagination


Discover how to make a flexible pagination system with CSS.


Simple Pagination

If you have a website with many pages, you might want to include a way to divide these pages into smaller sections for easier navigation.

Example

.pagination {
  display: inline-block;
}

.pagination a {
  color: black;
  float: left;
  padding: 8px 16px;
  text-decoration: none;
}
Try it Yourself »

Active and Hoverable Pagination

Make the currently displayed page stand out by adding the '.active' class. Additionally, use the ':hover' selector to alter the color of each page link when the mouse is moved over it.

Example

.pagination a.active {
  background-color: #4CAF50;
  color: white;
}

.pagination a:hover:not(.active) {background-color: #ddd;}
Try it Yourself »

Rounded Active and Hoverable Buttons

You can make a button look round when you click on it or hover over it by using the border-radius property. Just add it to your button's code.If you want to make a button look round when you click on it or hover over it, you can use the border-radius property.

Example

.pagination a {
  border-radius: 5px;
}

.pagination a.active {
  border-radius: 5px;
}
Try it Yourself »

Hoverable Transition Effect

You can make a hover effect for page links by adding the transition property to them.

Example

.pagination a {
  transition: background-color .3s;
}
Try it Yourself »

Bordered Pagination

You can create borders for pagination by using the border property in your HTML code.

Example

.pagination a {
  border: 1px solid #ddd; /* Gray */
}
Try it Yourself »

Rounded Borders

Hint: Make the edges of the first and last links in the pagination appear rounded by adding rounded borders.

Example

.pagination a:first-child {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.pagination a:last-child {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}
Try it Yourself »

Space Between Links

Hint: If you don't want to group the page links, you can use the margin property.

Example

.pagination a {
  margin: 0 4px; /* 0 is for top and bottom. Feel free to change it */
}
Try it Yourself »

Pagination Size

Adjust the pagination's size using the font-size property:

Example

.pagination a {
  font-size: 22px;
}
Try it Yourself »

Centered Pagination

To make the pagination appear in the middle of the page, put it inside a container (such as a <div>) and set the text alignment to center using the "text-align:center" code.

Example

.center {
  text-align: center;
}
Try it Yourself »

More Examples


Breadcrumbs

A different type of pagination is known as breadcrumbs.

Example

ul.breadcrumb {
  padding: 8px 16px;
  list-style: none;
  background-color: #eee;
}

ul.breadcrumb li {display: inline;}

ul.breadcrumb li+li:before {
  padding: 8px;
  color: black;
  content: "/\00a0";
}
Try it Yourself »