📖 Scenario: You are building a simple website that shows a list of items spread across multiple pages. To help users navigate between pages, you want to add a pagination control at the bottom.
🎯 Goal: Create a Bootstrap pagination component with page numbers and navigation arrows that users can click to move between pages.
📋 What You'll Learn
Use Bootstrap 5 pagination classes
Create a pagination bar with page numbers 1 to 5
Include Previous and Next navigation arrows
Mark page 3 as the active page
Ensure the pagination is accessible with proper aria-labels
💡 Why This Matters
🌍 Real World
Pagination is used on websites to split content into pages, making it easier for users to browse large lists or search results.
💼 Career
Web developers often need to implement pagination controls to improve user experience and navigation on data-heavy websites.
Progress0 / 4 steps
1
Create the basic pagination container
Write the HTML code to create a <nav> element with aria-label="Page navigation example". Inside it, add an unordered list <ul> with the Bootstrap class pagination.
Bootsrap
Hint
The <nav> element helps screen readers understand this is navigation. The aria-label describes the navigation purpose.
2
Add Previous and Next navigation arrows
Inside the <ul class="pagination">, add two list items <li> with class page-item. The first is for the Previous arrow with a link <a> containing « and aria-label="Previous". The second is for the Next arrow with a link containing » and aria-label="Next".
Bootsrap
Hint
The « and » symbols represent left and right arrows. Use aria-label to describe them for screen readers.
3
Add page number links 1 to 5
Between the Previous and Next list items, add five <li> elements with class page-item. Each should contain a link <a> with class page-link and text from 1 to 5. Make sure the page number 3's <li> has the class active and includes aria-current="page".
Bootsrap
Hint
The active page uses the active class and aria-current="page" for accessibility.
4
Complete the pagination with proper structure
Ensure the entire pagination component is wrapped inside the <nav> with aria-label="Page navigation example". Confirm all <li> elements have the class page-item and all links have the class page-link. The active page is page 3 with aria-current="page".
Bootsrap
Hint
Check that all parts are included and the structure matches Bootstrap's pagination pattern.
Practice
(1/5)
1. What is the main purpose of the Bootstrap pagination component?
easy
A. To create dropdown menus
B. To style buttons with different colors
C. To divide content into multiple pages for easier navigation
D. To add animations to images
Solution
Step 1: Understand pagination concept
Pagination is used to split large content into smaller pages for better user experience.
Step 2: Recognize Bootstrap pagination role
Bootstrap's pagination component helps create navigation links for these pages.
Final Answer:
To divide content into multiple pages for easier navigation -> Option C
Quick Check:
Pagination = divide content into pages [OK]
Hint: Pagination breaks content into pages for easy reading [OK]
Common Mistakes:
Confusing pagination with dropdown menus
Thinking pagination styles buttons only
Assuming pagination adds animations
2. Which of the following is the correct Bootstrap class to create a pagination list container?
easy
A. pagination-list
B. pagination
C. page-container
D. page-list
Solution
Step 1: Identify Bootstrap pagination container class
The main container for pagination uses the class pagination.
Step 2: Verify other options
Classes like pagination-list, page-container, and page-list are not valid Bootstrap classes.
Final Answer:
pagination -> Option B
Quick Check:
Pagination container class = pagination [OK]
Hint: Use class 'pagination' for the pagination container [OK]
Common Mistakes:
Using non-existent classes like pagination-list
Confusing container class with item classes
Misspelling the class name
3. Given the following Bootstrap pagination HTML, what will be the visual output in the browser?
A. The 'active' class is incorrectly placed on 'page-link' instead of 'page-item'
B. Missing href attribute on the anchor tags
C. The <ul> tag should have class 'page-list' instead of 'pagination'
D. The list items should not contain anchor tags
Solution
Step 1: Check class placement for active page
Bootstrap requires the active class on the page-item <li>, not on the page-link.
Step 2: Verify other attributes
All anchor tags have href attributes, the <ul> has correct class pagination, and anchors are required inside list items.
Final Answer:
The 'active' class is incorrectly placed on 'page-link' instead of 'page-item' -> Option A
Quick Check:
Active class belongs on page-item [OK]
Hint: Put 'active' on
, not on <a> [OK]
Common Mistakes:
Placing active class on anchor instead of list item
Removing href attribute from links
Using wrong class names on <ul>
5. You want to create a pagination component with 5 pages, where page 3 is active, and the 'Previous' button is disabled on page 1 only. Which Bootstrap structure correctly implements this behavior?
hard
A.
B.
C.
D.
Solution
Step 1: Check 'Previous' button disabled only on page 1
correctly disables the 'Previous' button with disabled class on the first page.
Step 2: Verify active page and order
Page 3 is marked active with active class and aria-current="page". Pages are in correct order 1 to 5.
Step 3: Confirm other buttons are enabled
Other page items and 'Next' button are enabled and clickable.
Final Answer:
Option A correctly implements the required pagination structure -> Option A
Quick Check:
Disabled Previous on page 1, active page 3, correct order [OK]
Hint: Disable 'Previous' only on first page, active class on current page [OK]
Common Mistakes:
Disabling wrong buttons
Incorrect order of page numbers
Placing active class on wrong page or element
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.