Caption-side - CSS Property

caption-side

Summary of characteristics of the caption-side property

Quick description
Positions the title of a table.
Status
Standard
Predefined values
top | bottom
Percentages
Not applicable.
Initial value
top
Inherited by default
Yes.
Discrète: during an animation, the caption-side property passes from one value to another without transition.
Single: single value (no order).
W3C Module
CSS Table Module
 🡇  
 🡅  
Document status: WD (Working Draft)

Document status: REC (Recommendation)

Syntax diagram of caption-side.

Syntax diagram of caption-side
Syntax diagram of the caption-side property.
Download the diagram in SVG.

Description of the caption-side property.

caption-side sets the position of a table's title. This title should be a caption tag included inside the table tag, before the tbody tag.

Example of HTML code for a table that includes the caption tag.

table captionTable title/caption tbody tr td.../td ... /tr /tbody /table

Note: this property can be applied to the caption tag or the table tag.

The text-align property can be used together with caption-side to complete the positioning of the table title.

Language support.

The top and bottom values are actually logical values that take writing direction into account. So, the table title can end up on the right or left if the writing direction is vertical (values vertical-lr or vertical-rl assigned to the writing-mode property). The simulator below lets you see how this works.

top
The direction and writing mode of this text adapt to the chosen language.
bottom

Values for caption-side.

  • caption-side: top;

    Default value. The caption is placed at the beginning of the table. So this value is treated as if it were block-start. If the writing mode is European, the caption will be positioned above the table, but this might not necessarily be the case in other writing modes (see the property writing-mode ).

    Table title
    ABC
    ABC
    ABC
  • caption-side: bottom;

    The title is positioned at the end of the table (value treated as block-end). In European writing mode, the title is placed below the table, but in other writing modes, the title can be placed elsewhere (see the writing-mode property).

    Table title
    ABC
    ABC
    ABC
  • caption-side: initial; (top) caption-side: inherit; caption-side: revert; caption-side: revert-layer; caption-side: revert-rule; caption-side: unset;

    Common values ​​are presented on these pages: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the caption-side property.

Animating caption-side is possible but, in our opinion, not very interesting.

Table title
   
   

Access the caption-side property via a program

Change the position of table titles with Javascript.

In JavaScript, here's how to change the value of caption-side. You can see that JavaScript offers a syntax with the typical CSS-style notation, in kebab-case (a dash to separate words), and another syntax with camelCase notation (a capital letter to separate words).

Javascript
let el = document.getElementById('id'); el.style['caption-side'] = 'bottom'; // or let el = document.getElementById('id'); el.style.captionSide = 'bottom';

Read the table title position with Javascript.

The property must have been applied directly to the element itself via its style attribute, not through a CSS selector. It will also work correctly if the property was set by the code above.

Javascript
let el = document.getElementById('id'); let value = el.style['caption-side']; // or let el = document.getElementById('id'); let value = el.style.captionSide;

Retrieving the computed value of caption-side with JavaScript.

The computed value is the one that comes from evaluating the chain of inheritances. By default, it's the initial value. The computed value is always defined.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('caption-side');

Read or change the position of titles with JQuery.

JQuery

// Read the value:
$('#id').prop('caption-side');
// Write the value:
$('#id').prop('caption-side', 'bottom');
$('#id').prop('{caption-side': 'bottom'});

Retrieving the computed value of caption-side with JQuery.

JQuery
let value = $('#id').css('caption-side');

Try it yourself.

The buttons below apply the entered value to the caption-side property and then show either the value as applied, or the computed value. If the displayed applied value is empty, it means the value you entered is incorrect.

Simulator.


caption-side :

text-align :

writing-mode :

 

Table title
JanuaryFebruaryMarchApril
MayJuneJulyAugust
SeptemberOctoberNovemberDecember

Browsers compatibility with caption-side.

The table below shows that the property caption-side is indeed recognized by browsers. However, some points of the specification regarding logical values are not handled correctly.

Column 1
Support for the caption-side property to define the position of a caption of a table.
Column 2
Support for the values top and bottom treated as relative values to the writing mode.
1
caption-side
property
2
caption-side
(logical values)
Estimated overall support.
96%
2%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Safari sur IOS

Opéra

Chrome

Edge

Firefox

Chrome pour Androïd

Samsung Internet

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the caption-side property.

  • Cascading Style Sheets Level 2 - Revision 1 Specification

    This level 2 of the specification describes the mechanism of cascading styles in CSS. This language is used to format HTML or XML documents. It supports media-specific style sheets so that authors can adapt the presentation of their documents for visual browsers, auditory devices, printers, braille devices, portable devices, etc.

    Regarding caption-side Initial definition of the caption-side property.
    WD
    November 04, 1997
    Working Draft.
    PR
    March 24, 1998
    Proposed for recommendation.
    REC
    May 11, 1998
    Recommendation .
  • CSS Table Module Level 3

    This specification module defines a table-based layout system, optimized for the rendering of tabular data. In this layout model, each cell is assigned to an intersection between a set of consecutive rows and a set of consecutive columns, which are themselves generated from the structure of the table and sized according to their content.

    Regarding caption-side No change regarding caption-side.
    WD
    October 25, 2016
    Working Draft.
    CR
    PR
    REC

See also, about the tables.

The W3C specification "CSS Table Module" brings together all the definitions specifically about table formatting. There aren't actually that many, but a lot of more general properties can apply to tables: dimensions, margins, etc.

Properties:

border-collapse
How table cells are framed.
border-spacing
Langue française
The spacing between adjacent cells in a table, when they are not merged.
Caption-side
Positions the title of a table.
empty-cells
Langue française
Defines whether empty cells in a table should be displayed (borders, background color and image, and so on).
table-layout
Langue française
Defines how the column widths of a table are calculated when not explicitly specified.