How TO - CSS Pagination


Learn how to create a pagination with CSS.


How To Create a Pagination

Try it Yourself »


Step 1) Add HTML:

Example

<div class="pagination">
  <a href="#">&laquo;</a>
  <a href="#">1</a>
  <a class="active" href="#">2</a>
  <a href="#">3</a>
  <a href="#">4</a>
  <a href="#">5</a>
  <a href="#">6</a>
  <a href="#">&raquo;</a>
</div>
Step 2) Add CSS:

Example

/* Pagination links */
.pagination a {
  color: black;
  float: left;
  padding: 8px 16px;
  text-decoration: none;
  transition: background-color .3s;
}

/* Style the active/current link */
.pagination a.active {
  background-color: dodgerblue;
  color: white;
}

/* Add a grey background color on mouse-over */
.pagination a:hover:not(.active) {background-color: #ddd;}
Try it Yourself »

Go to our CSS Pagination Tutorial to learn more about pagination.


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.