Question
Bootstrap Table Text Alignment Classes: Right-Align Currency Values
Question
Is there a built-in Twitter Bootstrap class for aligning text inside table cells? For example, how can I right-align a totals header and a currency value?
<th class="align-right">Total</th>
<td class="align-right">$1,000,000.00</td>
Short Answer
You will learn how Bootstrap text-alignment utility classes work in tables, which class to use for each Bootstrap version, and why currency columns are usually right-aligned.
Concept
Bootstrap provides utility classes: small, reusable CSS classes that apply one focused style. Text alignment utilities set CSS's text-align property.
For a numeric table column, apply the utility directly to the <th> and <td> elements. This keeps the alignment attached to the content that needs it.
Bootstrap class names depend on the version:
- Bootstrap 3 and 4:
.text-left,.text-center,.text-right - Bootstrap 5:
.text-start,.text-center,.text-end
Bootstrap 5 uses logical directions: start means the beginning of the current writing direction, and end means the end. In a typical left-to-right English page, .text-end aligns text to the right. This also makes layouts work better in right-to-left languages.
Right-aligning currency and other numbers makes digits and decimal points easier to compare down a column.
Mental Model
Think of a table column as a row of numbers written on a sheet of accounting paper. If every amount ends at the same right-hand edge, the decimal places form a neat vertical line. Your eye can quickly compare $25.00, $125.00, and $1,000.00.
A Bootstrap alignment utility is like placing a small instruction label on a cell: “put all text at this edge.” The cell still contains the same value; only its presentation changes.
Syntax and Examples
Use the alignment class on the table cell or header.
Bootstrap 5
<table class="table">
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col" class="text-end">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Server subscription</td>
<td class="text-end">$1,000,000.00</td>
</tr>
</tbody>
</table>
.text-end right-aligns the header and currency cell in a standard left-to-right document.
Bootstrap 3 or Bootstrap 4
<table class="table">
<tr>
<th>Product</th>
<th class="text-right">Total</th>
</tr>
<tr>
<td>Server subscription</td>
<td class="text-right">$1,000,000.00</td>
</tr>
</table>
Use .text-right for Bootstrap 3 and 4. A custom class such as .align-right does nothing unless your own CSS defines it.
Step by Step Execution
Consider this Bootstrap 5 example:
<tr>
<td>Annual plan</td>
<td class="text-end">$120.00</td>
</tr>
- The browser creates a table row with two cells.
- The first
<td>has no alignment utility, so it uses the page's normal text alignment, usually left-aligned in English. - The second
<td>has thetext-endclass. - Bootstrap's stylesheet contains a rule equivalent to:
.text-end {
text-align: right;
}
- The browser places
$120.00against the right edge of that cell.
In a Bootstrap 3 or 4 project, replace text-end with text-right; the result is the same for a left-to-right page.
Real World Use Cases
- Invoices: right-align unit prices, taxes, discounts, and invoice totals.
- Financial dashboards: align revenue, balances, exchange rates, and percentage columns for quick comparison.
- Admin tables: center compact status indicators while leaving names left-aligned and amounts right-aligned.
- Reports: align dates, quantities, and calculated values consistently across many rows.
- Responsive interfaces: use breakpoint variants to change alignment when a table becomes a stacked mobile layout.
Real Codebase Usage
In projects, developers usually choose alignment based on the data type and apply it consistently across an entire column.
Keep headers and values aligned
<th scope="col" class="text-end">Amount</th>
<td class="text-end">$49.99</td>
If only the body cells are right-aligned, the header can look disconnected from its column.
Use responsive alignment when needed
Bootstrap 5 supports breakpoint variants:
<td class="text-start text-md-end">$49.99</td>
This is start-aligned on small screens and end-aligned from the md breakpoint upward. It can help when a mobile layout needs more readable stacked content.
Use semantic table markup
<th scope="col" class="text-end">Total</th>
scope="col" helps assistive technologies understand that the header labels a column. Alignment is visual; semantic HTML describes what the data means.
For repeated columns in a server-rendered template or component, teams often store a column's display settings in one configuration object or reusable table component so every table follows the same conventions.
Common Mistakes
Using a class that Bootstrap does not provide
This does not work by itself:
<td class="align-right">$1,000.00</td>
align-right is not a standard Bootstrap text utility. Use .text-right in Bootstrap 3/4 or .text-end in Bootstrap 5, or define your own CSS.
Mixing up Bootstrap versions
<td class="text-right">$1,000.00</td>
This is correct in Bootstrap 3 and 4, but Bootstrap 5 uses .text-end. Check the version actually loaded by the project before choosing a class.
Using pull-right or float-end for cell content
Float utilities move an element out of normal flow and are not the right tool for aligning all text in a table cell.
<td><span class="float-end">$1,000.00</span></td>
Prefer this:
<td class="text-end">$1,000.00</td>
Aligning only some cells in a numeric column
A column is harder to scan when some values are left-aligned and others are right-aligned. Apply the same class to the header and every relevant data cell.
Expecting text alignment to change the column width
text-align controls where content sits inside a cell. It does not set the cell's width. Use table layout rules, CSS widths, or Bootstrap sizing/layout utilities when width is the actual issue.
Comparisons
| Need | Bootstrap 3/4 | Bootstrap 5 | Notes |
|---|---|---|---|
| Align text left | .text-left | .text-start | start adapts to writing direction. |
| Center text | .text-center | .text-center | Same class name. |
| Align text right | .text-right | .text-end | Use for typical currency columns. |
| Float an element | .pull-right in v3 / float utilities in later versions | .float-end | Not the preferred solution for normal cell text alignment. |
text-align affects inline content within an element, such as text, inline links, and inline icons. A float utility changes how an element is positioned in the document flow. For a table value, text alignment is simpler and more predictable.
Cheat Sheet
<!-- Bootstrap 5: right-align a table value -->
<td class="text-end">$1,000.00</td>
<!-- Bootstrap 3/4: right-align a table value -->
<td class="text-right">$1,000.00</td>
| Version | Left/start | Center | Right/end |
|---|---|---|---|
| Bootstrap 3 | .text-left | .text-center | .text-right |
| Bootstrap 4 | .text-left | .text-center | .text-right |
| Bootstrap 5 | .text-start | .text-center | .text-end |
- Apply the class to
<th>and<td>elements. - Use right/end alignment for currency and comparable numeric values.
- Use
scope="col"on column header cells when appropriate. - Use
text-start text-md-endwhen alignment should change by screen size. text-aligndoes not control cell or column width.
FAQ
Which Bootstrap class right-aligns text in a table?
Use .text-end in Bootstrap 5. Use .text-right in Bootstrap 3 or 4.
Why does .align-right not work in Bootstrap?
It is not a built-in Bootstrap text alignment class. It will work only if your project defines CSS for it.
Should currency values be right-aligned in HTML tables?
Usually, yes. Right alignment makes values with different digit lengths easier to compare vertically.
Is .text-right available in Bootstrap 5?
No. Bootstrap 5 uses .text-end instead of directional .text-right.
Can I center text in a Bootstrap table cell?
Yes. Add .text-center to the <td> or <th> in supported Bootstrap versions.
Does .text-end always mean right-aligned?
In a typical left-to-right document, yes. In a right-to-left document, “end” can be the left side. This is intentional because Bootstrap 5 uses direction-aware logical alignment.
Can I align a full table column with one class?
HTML does not let a class on one header automatically style every body cell. Add the utility to each relevant <th> and <td>, or use project CSS or a reusable table component for repeated columns.
Mini Project
Description
Build a small invoice summary table using Bootstrap. The table demonstrates a common reporting convention: descriptions are start-aligned, while quantities and monetary values are end-aligned for easy scanning.
Goal
Create a Bootstrap 5 invoice table with consistently aligned numeric and currency columns.
Requirements
Use Bootstrap 5 in the page. Create a table with Item, Quantity, Unit Price, and Total columns. End-align the Quantity, Unit Price, and Total headers and values. Include at least three invoice rows. Add a final total row that is visually emphasized.
Keep learning
Related questions
Angular ngClass Conditional Class Binding Explained
Learn how to use Angular ngClass for conditional classes, fix common binding mistakes, and understand why this template error happens.
Apply CSS to an iframe: Same-Origin Styling in HTML
Learn why parent-page CSS does not style iframe content, how same-origin rules work, and practical ways to style embedded pages safely.
Apply Multiple CSS Transforms: rotate() and translate()
Learn how to combine multiple CSS transform functions such as rotate() and translate(), understand transform order, and avoid overwritten rules.