YouTip LogoYouTip

Css3 Pagination

In this chapter, we will introduce how to create pagination examples using CSS.


Simple Pagination

If your website has many pages, you need to use pagination to navigate each page.

The following example demonstrates how to use HTML and CSS to create pagination:

CSS Example

ul.pagination {
    display: inline-block;
    padding: 0;
    margin: 0;
}

ul.pagination li {display: inline;}

ul.pagination li a {
    color: black;
    float: left;
    padding: 8px 16px;
    text-decoration: none;
}

Try it Β»


Click and Hover Pagination Styles

If you click the current page, you can use the .active class to style the current page. For mouse hover, you can use the :hover selector to modify the style:

CSS Example

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

ul.pagination li a:hover:not(.active) {background-color: #ddd;}

Try it Β»

CSS Example

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

ul.pagination li a:hover:not(.active) {background-color: #ddd;}

Try it Β»

Rounded Style

You can use the border-radius property to add rounded corners to the selected page number:

CSS Example

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

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

Try it Β»

Hover Transition Effect

We can add a transition effect when the mouse moves over a page number by adding the transition property:

CSS Example

ul.pagination li a {
    transition: background-color .3s;
}

Try it Β»


Border Pagination

We can use the border property to add borders to pagination:

CSS Example

ul.pagination li a {
    border: 1px solid #ddd; /* Gray */
}

Try it Β»

Rounded Borders

Tip: Add rounded corners to the first and last pagination links:

CSS Example

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

.pagination li:last-child a {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

Try it Β»

Pagination Spacing

Tip: You can use the margin property to add space between each page number:

CSS Example

ul.pagination li a {
    margin: 0 4px; /* 0 corresponds to top and bottom, you can modify it to see the effect */
}

Try it Β»


Pagination Font Size

We can use the font-size property to set the font size of the pagination:

CSS Example

ul.pagination li a {
    font-size: 22px;
}

Try it Β»


Center Pagination

To center the pagination, you can add the text-align:center style to the container element (e.g., <div>):

CSS Example

div.center {
    text-align: center;
}

Try it Β»


More Examples


Breadcrumb Navigation

  • Home
  • Frontend
  • HTML Tutorial
  • HTML Paragraphs

Another type of navigation is breadcrumb navigation, as shown in the example below:

CSS 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: "/0a0";
}

Try it Β»

← Css3 PaginationProp Style Filter β†’