#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Bootstrap Fundamentals

Tables

Bootstrap table styles turn a plain HTML <table> into a readable, consistently spaced data table by adding a few classes. You use them for things like price lists, timetables, order histories and admin screens, anywhere rows and columns of real data need to be shown.

Starting with the base class

Bootstrap deliberately leaves raw tables unstyled, because tables are also used inside other widgets. To opt in, add class="table". That single class gives you padding in each cell, horizontal dividers and full width. Everything else builds on top of it.

<div class="table-responsive">
  <table class="table table-striped table-hover align-middle">
    <caption>Recent orders</caption>
    <thead class="table-light">
      <tr>
        <th scope="col">Order</th>
        <th scope="col">Customer</th>
        <th scope="col" class="text-end">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">#1021</th>
        <td>Riya</td>
        <td class="text-end">1,250.00</td>
      </tr>
      <tr class="table-warning">
        <th scope="row">#1022</th>
        <td>Arjun</td>
        <td class="text-end">640.00</td>
      </tr>
    </tbody>
  </table>
</div>

Modifier classes you will use most

ClassEffect
table-stripedShades every other row in the body.
table-hoverHighlights a row when the mouse is over it.
table-borderedAdds borders on every side of every cell.
table-borderlessRemoves all borders.
table-smHalves the cell padding for dense data.
table-darkLight text on a dark background.

These can be combined freely. A compact, striped admin list might use table table-sm table-striped. Striping helps the eye follow a long row across many columns, while hover is most useful when clicking a row opens a detail view. If rows are not clickable, hover can mislead users into thinking they are, so add it only when it means something.

Under the hood, Bootstrap 5 drives these styles with CSS variables such as --bs-table-bg and --bs-table-striped-bg. That means you can adjust colours for one table in your own stylesheet without overriding long selector chains.

Colouring rows and cells

Contextual classes such as table-success, table-danger, table-warning and table-info can be placed on a <tr>, a single <td>, or the whole table. They are useful for marking a failed payment or a low-stock item. Colour alone is not enough for people who cannot see it, so pair it with text such as "Overdue" in a status column.

For header rows, table-light or table-dark on the <thead> gives a distinct header band. Vertical alignment inside rows is set with align-middle, align-top or align-bottom.

The mobile pitfall: tables that overflow

Tables do not shrink the way text does. A table with six or seven columns will push past a phone screen and create a sideways scroll on the whole page, which feels broken. Wrap it in <div class="table-responsive"> so only the table area scrolls horizontally. Use table-responsive-md or a similar variant if you want the scroll only below a certain breakpoint.

Another frequent mistake is placing the responsive class on the <table> itself. It must go on a wrapping element, otherwise it does nothing.

Keeping tables accessible

  • Use <th> for headings and add scope="col" or scope="row" so screen readers can link each cell to its heading.
  • Add a <caption> describing the table. Bootstrap places it below the table by default; caption-top on the table moves it above.
  • Right-align numbers with text-end so digits line up and are easier to compare.

Remember: table first, modifiers second, and a table-responsive wrapper around any table that might be wider than a phone.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course