CSS caption-side Property
The caption-side property controls whether a table caption appears above or below its table.
It is commonly used with the HTML <caption> element to position descriptive table titles without changing the order of the HTML markup. The default placement is above the table, but CSS can move the caption below it.
The property applies to elements displayed as table captions, including HTML <caption> elements and elements using display: table-caption.
caption-side Syntax
Use caption-side to specify the position of a table caption.
caption {
caption-side: bottom;
}
The standard syntax is:
selector {
caption-side: top | bottom;
}
Caption Above the Table
caption {
caption-side: top;
}
Caption Below the Table
caption {
caption-side: bottom;
}
Target a Specific Table
.sales-table caption {
caption-side: bottom;
}
CSS-Wide Keywords
caption {
caption-side: inherit;
}
caption {
caption-side: initial;
}
caption {
caption-side: unset;
}
caption {
caption-side: revert;
}
caption {
caption-side: revert-layer;
}
The CSS 2.2 definition includes top and bottom. CSS Table Module Level 3 also defines logical values such as block-start and block-end, but browser support for these newer values is limited.
Property Values
The two widely supported values are top and bottom.
| Value | Description |
|---|---|
top |
Positions the caption above the table. This is the initial value. |
bottom |
Positions the caption below the table. |
Additional Specification Values
CSS Table Module Level 3 defines additional logical caption positions. These values are not consistently implemented in mainstream browsers.
| Value | Description |
|---|---|
block-start |
Positions the caption at the block-start side of the table. |
block-end |
Positions the caption at the block-end side of the table. |
inline-start |
Positions the caption at the inline-start side of the table. |
inline-end |
Positions the caption at the inline-end side of the table. |
For production websites, top and bottom remain the dependable choices.
CSS-Wide Keywords
| Value | Description |
|---|---|
inherit |
Uses the computed value from the parent element. |
initial |
Resets the property to top. |
unset |
Uses the inherited value because the property is inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | top |
| Inherited | Yes |
| Applies to | Table caption boxes |
| Computed value | Specified keyword |
| Animation type | Discrete |
| Percentages | Not applicable |
| Primary use | Positioning table captions |
The property changes the visual position of a caption without changing the order of the elements in the HTML document.
How It Works
A table caption is associated with a table and is normally displayed above its rows.
Step 1: Create a Table
<table>
<caption>Monthly Website Traffic</caption>
<thead>
<tr>
<th scope="col">Month</th>
<th scope="col">Visitors</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>1,250</td>
</tr>
<tr>
<td>February</td>
<td>1,480</td>
</tr>
</tbody>
</table>
Step 2: Position the Caption Above the Table
caption {
caption-side: top;
}
The caption appears above the table, which is the default placement.
Step 3: Move the Caption Below the Table
caption {
caption-side: bottom;
}
The caption moves below the table while remaining the first child of the <table> element in the HTML.
Step 4: Style the Caption
caption {
caption-side: bottom;
padding: 10px;
font-weight: bold;
text-align: center;
}
The additional declarations control the caption's appearance, not its placement.
Step 5: Target Individual Tables
.summary-table caption {
caption-side: top;
}
.details-table caption {
caption-side: bottom;
}
Different tables can use different caption positions without changing their HTML structure.
Captions Above Tables
The top value positions the caption above the table and is the initial value.
caption {
caption-side: top;
}
HTML Example
<table class="employee-table">
<caption>Employee Directory</caption>
<tr>
<th scope="col">Name</th>
<th scope="col">Department</th>
</tr>
<tr>
<td>Alex</td>
<td>Design</td>
</tr>
</table>
CSS Example
.employee-table caption {
caption-side: top;
padding-bottom: 10px;
font-weight: bold;
}
Default Behavior
Because top is the initial value, it is not necessary to declare it unless you are overriding another caption position.
When to Use Top
Captions above tables are useful when readers should know what the table represents before examining its data.
This placement is common in reports, dashboards, tutorials, and reference documents.
Captions Below Tables
The bottom value positions the caption below the table.
caption {
caption-side: bottom;
}
HTML Example
<table class="sales-table">
<caption>Quarterly Sales Summary</caption>
<tr>
<th scope="col">Quarter</th>
<th scope="col">Sales</th>
</tr>
<tr>
<td>Q1</td>
<td>$12,500</td>
</tr>
</table>
CSS Example
.sales-table caption {
caption-side: bottom;
padding-top: 10px;
font-style: italic;
}
Caption Remains in the Table
The <caption> element remains inside the <table> element in the HTML. Only its visual placement changes.
When to Use Bottom
Bottom captions can be useful for tables presented as figures, supporting data, or examples where a description follows the displayed information.
Choose the placement that makes the table easiest to understand within the surrounding content.
Caption Alignment
The caption-side property controls vertical placement, while text-align controls the horizontal alignment of caption text.
Left-Aligned Caption
caption {
caption-side: top;
text-align: left;
}
Centered Caption
caption {
caption-side: top;
text-align: center;
}
Right-Aligned Caption
caption {
caption-side: bottom;
text-align: right;
}
Logical Text Alignment
caption {
caption-side: top;
text-align: start;
}
The start value follows the inline-start direction of the text, making it useful for multilingual layouts.
Caption Alignment vs. Table Alignment
Aligning caption text does not necessarily align the entire table within its container.
Use table width and margin properties to control table placement separately.
Caption Spacing
Padding and margins can create space between a caption and its table.
Spacing Below a Top Caption
caption {
caption-side: top;
padding-bottom: 12px;
}
Spacing Above a Bottom Caption
caption {
caption-side: bottom;
padding-top: 12px;
}
Padding Around a Caption
caption {
caption-side: top;
padding: 10px 15px;
}
Caption Background
caption {
caption-side: top;
padding: 12px;
background-color: #e8f3fb;
}
Consistent Table Spacing
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table caption {
caption-side: bottom;
padding-top: 10px;
}
Spacing helps visually separate the caption from the table while preserving their relationship.
Caption Styling
Table captions can be styled using standard text and background properties.
Font Weight
caption {
font-weight: bold;
}
Font Size
caption {
font-size: 1.125rem;
}
Text Color
caption {
color: #1769aa;
}
Background Color
caption {
padding: 10px;
background-color: #e8f3fb;
}
Italic Caption
caption {
caption-side: bottom;
font-style: italic;
}
Complete Caption Style
.data-table caption {
caption-side: top;
padding: 12px;
color: #1769aa;
background-color: #e8f3fb;
font-size: 1.125rem;
font-weight: bold;
text-align: left;
}
Keep caption text readable and visually connected to its table. Styling should reinforce the caption's purpose rather than make it look unrelated to the data.
Table Caption Display
The caption-side property applies to table caption boxes, which normally come from the HTML <caption> element.
Native HTML Caption
<table>
<caption>Product Inventory</caption>
<tr>
<th scope="col">Product</th>
<th scope="col">Quantity</th>
</tr>
<tr>
<td>Keyboard</td>
<td>24</td>
</tr>
</table>
Default Display Type
caption {
display: table-caption;
}
Browsers normally give HTML captions the table-caption display type automatically.
Custom Table Caption Box
.custom-caption {
display: table-caption;
caption-side: bottom;
}
This display value can create a caption box within an appropriate CSS table formatting context.
Avoid Unnecessary Display Changes
Changing a native <caption> element to an unrelated display type can interfere with its normal table-caption layout behavior.
For semantic HTML tables, prefer the native <caption> element and control its placement with caption-side.
Accessibility
The HTML <caption> element provides a descriptive title for a table and helps users understand its purpose.
Use a Meaningful Caption
<table>
<caption>Monthly Website Visitors for 2026</caption>
<thead>
<tr>
<th scope="col">Month</th>
<th scope="col">Visitors</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>1,250</td>
</tr>
</tbody>
</table>
Visual Position Does Not Change Semantics
caption {
caption-side: bottom;
}
Moving the caption visually does not change its semantic association with the table.
Keep the Caption in the Table
For a native HTML table, the <caption> element should be the first child of <table>.
Use Table Headers
<table>
<caption>Support Request Summary</caption>
<thead>
<tr>
<th scope="col">Status</th>
<th scope="col">Requests</th>
</tr>
</thead>
<tbody>
<tr>
<td>Open</td>
<td>12</td>
</tr>
</tbody>
</table>
Captions identify the table, while header cells identify the meaning of its rows and columns.
Avoid Using Captions Only for Decoration
Caption text should accurately describe the table. Decorative headings or unrelated text should not replace a meaningful caption.
Use caption-side for visual placement while preserving semantic table markup.
Responsive Tables
The caption-side property can be used with responsive tables, although the caption remains part of the table formatting context.
Responsive Table Wrapper
<div class="table-responsive">
<table class="data-table">
<caption>Quarterly Website Statistics</caption>
<tr>
<th scope="col">Quarter</th>
<th scope="col">Visitors</th>
<th scope="col">Page Views</th>
</tr>
<tr>
<td>Q1</td>
<td>12,500</td>
<td>34,800</td>
</tr>
</table>
</div>
CSS Example
.table-responsive {
max-width: 100%;
overflow-x: auto;
}
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table caption {
caption-side: top;
padding: 10px;
text-align: left;
}
Change Caption Placement at Smaller Widths
@media (max-width: 600px) {
.data-table caption {
caption-side: bottom;
}
}
This moves the caption below the table when the viewport is 600 pixels wide or narrower.
Responsive Considerations
Horizontal scrolling can help preserve the structure of wide data tables. Test the caption's placement and readability when the table overflows its container.
The caption-side property does not make a table responsive by itself.
Practical Uses
The caption-side property provides a simple way to control table caption placement.
Data Table Title
.data-table caption {
caption-side: top;
font-weight: bold;
}
Table Description Below Data
.report-table caption {
caption-side: bottom;
font-style: italic;
}
Centered Table Caption
.summary-table caption {
caption-side: top;
text-align: center;
}
Left-Aligned Table Caption
.details-table caption {
caption-side: top;
text-align: left;
}
Highlighted Caption
.highlight-table caption {
caption-side: top;
padding: 12px;
background-color: #e8f3fb;
}
Bottom Caption with Spacing
.example-table caption {
caption-side: bottom;
padding-top: 12px;
}
Different Caption Positions
.primary-table caption {
caption-side: top;
}
.secondary-table caption {
caption-side: bottom;
}
Use captions to describe the table's content, and choose their placement based on the needs of the surrounding page.
caption-side Example
The following example shows two tables with captions in different positions. The first caption appears above its table, while the second appears below.
<div class="caption-side-demo">
<table class="top-caption">
<caption>Monthly Visitors - Top Caption</caption>
<thead>
<tr>
<th scope="col">Month</th>
<th scope="col">Visitors</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>1,250</td>
</tr>
<tr>
<td>February</td>
<td>1,480</td>
</tr>
</tbody>
</table>
<table class="bottom-caption">
<caption>Monthly Visitors - Bottom Caption</caption>
<thead>
<tr>
<th scope="col">Month</th>
<th scope="col">Visitors</th>
</tr>
</thead>
<tbody>
<tr>
<td>March</td>
<td>1,620</td>
</tr>
<tr>
<td>April</td>
<td>1,750</td>
</tr>
</tbody>
</table>
</div>
.caption-side-demo table {
width: 100%;
margin-bottom: 25px;
border-collapse: collapse;
}
.caption-side-demo th,
.caption-side-demo td {
padding: 10px;
border: 1px solid #cccccc;
text-align: left;
}
.caption-side-demo th {
background-color: #e8f3fb;
}
.caption-side-demo caption {
padding: 10px;
color: #1769aa;
font-weight: bold;
text-align: center;
}
.caption-side-demo .top-caption caption {
caption-side: top;
}
.caption-side-demo .bottom-caption caption {
caption-side: bottom;
}
| Month | Visitors |
|---|---|
| January | 1,250 |
| February | 1,480 |
| Month | Visitors |
|---|---|
| March | 1,620 |
| April | 1,750 |
The first table uses caption-side: top, while the second uses caption-side: bottom.
Both captions remain inside their respective tables in the HTML. CSS changes only their visual placement.
Important Considerations
Keep the following points in mind when using caption-side:
- Purpose: Controls the placement of table captions.
- Initial value:
top. - Inheritance: The property is inherited.
- Top placement:
topdisplays the caption above the table. - Bottom placement:
bottomdisplays the caption below the table. - Element type: Applies to table caption boxes.
- HTML structure: A native
<caption>element should be the first child of its table. - Semantic meaning: Changing the caption's visual position does not change its relationship to the table.
- Text alignment: Use
text-alignto align caption text. - Spacing: Use padding and other applicable spacing properties to separate the caption from the table.
- Styling: Font, color, and background properties can change the caption's appearance.
- Logical values: Additional CSS Table Level 3 values have limited implementation support.
- Responsive layouts: The property can be used within media queries but does not make tables responsive.
- Accessibility: Use meaningful caption text to describe the table.
- Animation: Changes between caption positions are discrete.
- Browser compatibility:
topandbottomare widely supported.
Use the native HTML <caption> element for accessible table descriptions and caption-side to control where those descriptions appear.
Browser Support
The caption-side property is widely supported in modern browsers for the top and bottom values.
Additional logical values defined in CSS Table Module Level 3 have limited browser support and should not be relied on without testing.
caption {
caption-side: bottom;
}
This declaration places table captions below their tables in supporting browsers.
Compatibility Recommendation
Use top and bottom for predictable caption placement across mainstream browsers.
For current compatibility information, visit Can I Use? .
Specifications
The caption-side property is defined in CSS 2.2 and further developed in CSS Table Module Level 3.
CSS 2.2 - Caption Position and Alignment
These specifications define how captions are positioned relative to tables and describe the supported and proposed placement values.
