BEST SITE FOR WEB DEVELOPERS

CSS Tutorial

CSS HOME CSS Introduction CSS Syntax CSS Selectors CSS How To CSS Comments CSS Colors CSS Backgrounds CSS Borders CSS Margins CSS Padding CSS Height/Width CSS Box Model CSS Outline CSS Text CSS Fonts CSS Icons CSS Links CSS Lists CSS Tables CSS Display CSS Max-width CSS Position CSS Z-index CSS Overflow CSS Float CSS Inline-block CSS Align CSS Combinators CSS Pseudo-class CSS Pseudo-element CSS Opacity CSS Navigation Bar CSS Dropdowns CSS Image Gallery CSS Image Sprites CSS Attr Selectors CSS Forms CSS Counters CSS Website Layout CSS Units CSS Specificity CSS !important CSS Math Functions

CSS Advanced

CSS Rounded Corners CSS Border Images CSS Backgrounds CSS Colors CSS Color Keywords CSS Gradients CSS Shadows CSS Text Effects CSS Web Fonts CSS 2D Transforms CSS 3D Transforms CSS Transitions CSS Animations CSS Tooltips CSS Style Images CSS Image Reflection CSS object-fit CSS object-position CSS Masking CSS Buttons CSS Pagination CSS Multiple Columns CSS User Interface CSS Variables CSS Box Sizing CSS Media Queries CSS MQ Examples CSS Flexbox

CSS Responsive

RWD Intro RWD Viewport RWD Grid View RWD Media Queries RWD Images RWD Videos RWD Frameworks RWD Templates

CSS Grid

Grid Intro Grid Container Grid Item

CSS SASS

SASS Tutorial

CSS Examples

CSS Templates CSS Examples CSS Quiz CSS Exercises CSS Certificate

CSS References

CSS Reference CSS Selectors CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support

CSS Lessons for beginners

Ua

CSS Pagination Examples


Learn how to create a responsive pagination using CSS.


Simple Pagination

If you have a website with lots of pages, you may wish to add some sort of pagination to each page:

Example

.pagination {
  display: inline-block;
}

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

Active and Hoverable Pagination

Highlight the current page with an .active class, and use the :hover selector to change the color of each page link when moving the mouse over them:

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

Add the border-radius property if you want a rounded "active" and "hover" button:

Example

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

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

Hoverable Transition Effect

Add the transition property to the page links to create a transition effect on hover:

Example

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

Bordered Pagination

Use the border property to add borders to the pagination:

Example

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

Rounded Borders

Tip: Add rounded borders to your first and last link in the pagination:

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

Tip: Add the margin property if you do not want to group the page links:

Example

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

Pagination Size

Change the size of the pagination with the font-size property:

Example

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

Centered Pagination

To center the pagination, wrap a container element (like <div>) around it with text-align:center

Example

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

More Examples


Breadcrumbs

Another variation of pagination is so-called "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 »