{"id":248452,"date":"2016-12-29T06:14:29","date_gmt":"2016-12-29T13:14:29","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=248452"},"modified":"2022-02-01T08:26:07","modified_gmt":"2022-02-01T16:26:07","slug":"caption-side","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/c\/caption-side\/","title":{"rendered":"caption-side"},"content":{"rendered":"\n

The caption-side<\/code> property in CSS allows you to define where<\/em> to position HTML’s <caption><\/code> element, used on HTML table headers. This property can also apply to any element whose display<\/code> property is set to caption-side<\/code>.<\/p>\n\n\n\n\n\n\n\n

table {\n  caption-side: top;\n}<\/code><\/pre>\n\n\n

Syntax<\/h3>\n\n\n
caption-side: top | bottom | block-start | block-end | inline-start | inline-end<\/code><\/pre>\n\n\n\n
  • Initial value:<\/strong> top<\/code><\/li>
  • Applies to:<\/strong> table-caption elements<\/li>
  • Inherited:<\/strong> yes<\/li>
  • Computed value:<\/strong> as specified<\/li>
  • Animation type:<\/strong> discrete<\/li><\/ul>\n\n\n

    Values<\/h3>\n\n\n
    \/* Directional values *\/\ncaption-side: top;\ncaption-side: bottom;\n\n\/* Logical values *\/\ncaption-side: block-start;\ncaption-side: block-end;\ncaption-side: inline-start;\ncaption-side: inline-end;\n\n\/* Global values *\/\ncaption-side: inherit;\ncaption-side: initial;\ncaption-side: revert;\ncaption-side: unset;<\/code><\/pre>\n\n\n\n
    • top<\/code>:<\/strong> the default. Positions the caption at the top of the table.<\/li>
    • bottom<\/code>:<\/strong> Positions the caption at the bottom of the table.<\/li>
    • block-start<\/code>:<\/strong> Positions the caption at the table’s starting edge in the block direction.<\/li>
    • block-end<\/code>:<\/strong> Positions the caption at the table’s starting edge in the block direction.<\/li>
    • inline-start<\/strong><\/code>: Positions the caption at the table’s starting edge in the inline direction.<\/li>
    • inline-end<\/code>:<\/strong> Positions the caption at the table’s starting edge in the inline direction.<\/li>
    • inherit<\/code>:<\/strong> Indicates that the value is inherited from the caption-side<\/code> value of its parent<\/li><\/ul>\n\n\n\n

      The caption-side<\/code> property can be applied either to the <table><\/code> element or the <caption><\/code> element, with the same effect. While this property will affect the position of the caption box as a whole (a caption\u2019s display<\/code> value computes to table-caption<\/code>), it will not affect the alignment of text inside the box. Text inside the box may be aligned using the text-align<\/code> property.<\/p>\n\n\n\n

      Note that the above values for caption-side<\/code> are relative to the table\u2019s writing-mode<\/code>. For example, if a table is set to a vertical writing mode, then the top<\/code> and bottom<\/code> values will be relative to the direction of the table.<\/p>\n\n\n

      Examples of caption-side<\/code><\/h3>\n\n\n

      The demo below includes a \u201ctoggle\u201d button that toggles the table\u2019s caption-side<\/code> property between top<\/code> and bottom<\/code>, so you can see the difference using a table with many rows of data:<\/p>\n\n\n\n