BS5 Pagination

In Bootstrap 5, pagination is used to divide content into multiple pages and provide navigation links to easily switch between them. Here's an example of how to create pagination in Bootstrap 5:

html
<nav>
    <ul class="pagination">
        <li class="page-item">
            <a class="page-link" href="#" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
                <span class="visually-hidden">Previous</span>
            </a>
        </li>
        <li class="page-item"><a class="page-link" href="#">1</a></li>
        <li class="page-item"><a class="page-link" href="#">2</a></li>
        <li class="page-item"><a class="page-link" href="#">3</a></li>
        <li class="page-item">
            <a class="page-link" href="#" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
                <span class="visually-hidden">Next</span>
            </a>
        </li>
    </ul>
</nav>

In this example, a basic pagination component is created using the `<nav>` element with the class `pagination`. The individual pages are represented by `<li>` elements with the class `page-item`. Each page is linked using an anchor tag `<a>` with the class `page-link`.


The `aria-label` attribute is used to provide accessibility information for screen readers. The `&laquo;` and `&raquo;` are the Unicode characters for "previous" and "next" symbols, respectively.

To add more pages to the pagination, you can simply add more `<li>` elements with the appropriate page number and link.

You can further customize the pagination by applying different styles or adding additional classes to the pagination component and page items as per your project requirements.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext