0
0
Bootsrapmarkup~20 mins

Pagination component in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bootstrap Pagination Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What is the visual output of this Bootstrap pagination code?
Look at the following Bootstrap pagination HTML snippet. What will you see rendered in the browser?
Bootsrap
<nav aria-label="Page navigation example">
  <ul class="pagination">
    <li class="page-item"><a class="page-link" href="#">Previous</a></li>
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item active" aria-current="page"><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="#">Next</a></li>
  </ul>
</nav>
AA horizontal list of page numbers 1, 2, 3 with '2' highlighted as active, and 'Previous' and 'Next' links on sides.
BA vertical list of page numbers 1, 2, 3 with '2' highlighted as active, and 'Previous' and 'Next' links on top and bottom.
CA horizontal list of page numbers 1, 2, 3 with no highlight, and 'Previous' and 'Next' links disabled.
DA horizontal list of page numbers 1, 2, 3 with '3' highlighted as active, and 'Previous' and 'Next' links on sides.
Attempts:
2 left
💡 Hint
Bootstrap pagination uses horizontal layout by default and highlights the active page with a special style.
accessibility
intermediate
2:00remaining
Which attribute improves accessibility in this pagination component?
In the Bootstrap pagination example, which attribute helps screen readers understand the current page?
Bootsrap
<nav aria-label="Page navigation example">
  <ul class="pagination">
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item active" aria-current="page"><a class="page-link" href="#">2</a></li>
    <li class="page-item"><a class="page-link" href="#">3</a></li>
  </ul>
</nav>
Aclass="active" on the active page item
Baria-current="page" on the active page item
Chref="#" on all links
Daria-label="Page navigation example" on the nav element
Attempts:
2 left
💡 Hint
Screen readers use specific ARIA attributes to identify the current page.
📝 Syntax
advanced
2:00remaining
What error occurs with this incorrect Bootstrap pagination HTML?
This snippet has a mistake. What happens when you try to render it in a browser?
Bootsrap
<nav aria-label="Page navigation">
  <ul class="pagination">
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item active" aria-current="page"><a class="page-link" href="#">2</a></li>
    <li class="page-item"><a class="page-link" href="#">3</a></li>
  </ul>
</nav>
AThe first <li> is not closed, causing invalid HTML but browser renders with missing closing tag.
BSyntaxError: Missing closing tag for <ul>
CTypeError: Cannot read property 'classList' of undefined
DThe page numbers do not appear because of missing CSS classes
Attempts:
2 left
💡 Hint
Browsers try to fix missing closing tags but the HTML is invalid.
layout
advanced
2:00remaining
How to center the Bootstrap pagination horizontally on the page?
Given this pagination, which CSS class or style centers it horizontally?
Bootsrap
<nav aria-label="Page navigation example">
  <ul class="pagination">
    <li class="page-item"><a class="page-link" href="#">Previous</a></li>
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item active" aria-current="page"><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="#">Next</a></li>
  </ul>
</nav>
AAdd style "margin-left: auto; margin-right: auto;" to the <ul> element
BAdd style "text-align: center;" to the <nav> element
CAdd class "mx-auto" to the <nav> element
DAdd class "justify-content-center" to the <ul> element
Attempts:
2 left
💡 Hint
Bootstrap uses flexbox utilities to align pagination items.
🧠 Conceptual
expert
2:00remaining
What is the effect of adding 'disabled' class to a Bootstrap pagination item?
Consider this pagination item:
  • Previous
  • . What does the 'disabled' class do?
    Bootsrap
    <nav aria-label="Page navigation example">
      <ul class="pagination">
        <li class="page-item disabled"><a class="page-link" href="#">Previous</a></li>
        <li class="page-item"><a class="page-link" href="#">1</a></li>
        <li class="page-item active" aria-current="page"><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="#">Next</a></li>
      </ul>
    </nav>
    AIt adds a tooltip explaining the item is disabled.
    BIt only changes the color but the link remains clickable.
    CIt visually styles the item as disabled and prevents clicking by disabling pointer events.
    DIt removes the link from the DOM so it cannot be clicked.
    Attempts:
    2 left
    💡 Hint
    Bootstrap disables pointer events and changes style for disabled pagination items.