Home >Web Front-end >CSS Tutorial >How do I align text in tables using Bootstrap?

How do I align text in tables using Bootstrap?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-01 12:01:02889browse

How do I align text in tables using Bootstrap?

Text Alignment Classes in Bootstrap

In Bootstrap, there are various text alignment classes available to align text within tables.

Bootstrap 3

  • text-left: Aligns text to the left.
  • text-center: Centers text horizontally.
  • text-right: Aligns text to the right.
  • text-justify: Justifies text across the entire width.
  • text-nowrap: Prevents text wrapping.

Example:

<code class="html"><th class="text-right">Total</th>
<td>,000,000.00</td></code>

Bootstrap 4

Similar to Bootstrap 3, Bootstrap 4 also provides text alignment classes:

  • text-xs-left: Left-aligns text on all viewport sizes.
  • text-xs-center: Centers text on all viewport sizes.
  • text-xs-right: Right-aligns text on all viewport sizes.
  • Additionally, text-sm-left, text-md-left, text-lg-left, and text-xl-left specify left-alignment for specific viewport sizes (e.g., sm for small, md for medium, etc.).

Bootstrap 5

In Bootstrap 5, text-left has been replaced with text-start, and text-right has been replaced with text-end. Otherwise, the text alignment classes remain the same.

The above is the detailed content of How do I align text in tables using Bootstrap?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn