Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

caption-side — table caption placement

The CSS caption-side property selects the side of a table on which its caption appears. The core values top and bottom place it above or below the grid, respectively, in a horizontal writing mode.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

caption-side: top | bottom;

caption-side positions a caption box relative to the table grid. It applies to table-caption boxes, usually produced by a caption element. In a horizontal writing mode, top places the caption above the grid and bottom below it. The initial value is top.

The property is inherited: a declaration on table can pass its value to the caption unless the caption has its own winning declaration. inherit explicitly takes the parent's value. Positioning the whole caption and aligning its text are separate concerns — use text-align for the latter.

The names top and bottom do not mean physical top and bottom in every writing mode: they correspond to block-start and block-end according to the writing mode of the caption's containing block. The extension adding inline-start and inline-end is conditional; do not assume it is portable. The core syntax in this entry is limited to top and bottom.

The example explicitly sets writing-mode: horizontal-tb. The caption remains first in the table's markup, but caption-side: bottom displays it beneath the rows. Changing the value to top should move it above the grid without changing the table's content. The example requires local verification.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>caption-side example</title>
<style>
  table { writing-mode: horizontal-tb; border-collapse: collapse; }
  caption { caption-side: bottom; text-align: left; }
  th, td { border: 1px solid black; padding: 4px; }
</style>
<table>
  <caption>Scores</caption>
  <tr><th scope="col">Name</th><th scope="col">Points</th></tr>
  <tr><td>Ada</td><td>12</td></tr>
</table>
</html>

Result

Name | Points
Ada  | 12
Scores

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources