What is the CSS caption-side property?

The caption-side property in CSSCascading Style Sheets is used to define the place where you want your caption to be placed in a table. It is only used in HTML tables.

Syntax

caption-side: top|bottom|initial|inherit;

Property values

  • top: This places the caption above the table.

  • bottom: This places the caption below the table.

  • initial: This sets the value to its default value.

  • inherit: This inherits property from its parent value.

Code

The following is the basic HTMLHypertext Markup Language and CSS code to demonstrate the use of the caption-side property.

Explanation

In this example we have made a table that contains the details of an employee. We set the caption to be placed at the top so we can see that the caption is placed at the top. We can also place the caption at the bottom of the table instead of placing it at the top.

Free Resources