HTML | DOM Style captionSide Property
The DOM Style captionSide property is used to set or return the position of the caption in a table.
Syntax:
- To get the captionSide Property
object.style.captionSide
- To set the captionSide Property
object.style.captionSide = "bottom | top | initial | inherit"
Property Values:
- bottom: This is used to position the caption on the bottom.
Example-1:
<!DOCTYPE html><html><head><title>DOM Style captionSide Property</title><style>th,td {border: 2px solid black;padding: 10px;margin: 10px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style captionSide Property</b><table><captionid="caption1">List of books</caption><tr><th>Book</th><th>Author</th><th>Price</th></tr><tr><td>Head First Java</td><td>Bert Bates, Kathy Sierra</td><td>500</td></tr><tr><td>Introduction to Algorithms</td><td>CLRS</td><td>1000</td></tr></table><buttononclick="setCaptionSide()"style="margin-top: 10px">Set captionSide</button><!-- Script to set captionSide to bottom --><script>function setCaptionSide() {elem = document.querySelector('#caption1');elem.style.captionSide = 'bottom';}</script></body></html>chevron_rightfilter_noneOutput:
Before clicking the button:

After clicking the button:

- top: This is used to position the caption on the top. This is the default value.
Example-2:
<!DOCTYPE html><html><head><title>DOM Style captionSide Property</title><style>th,td {border: 2px solid black;padding: 10px;margin: 10px;}#caption1 {caption-side: bottom;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style captionSide Property</b><table><captionid="caption1">List of books</caption><tr><th>Book</th><th>Author</th><th>Price</th></tr><tr><td>Head First Java</td><td>Bert Bates, Kathy Sierra</td><td>500</td></tr><tr><td>Introduction to Algorithms</td><td>CLRS</td><td>1000</td></tr></table><buttononclick="setCaptionSide()"style="margin-top: 10px">Set captionSide</button><!-- Script to set captionSide to top --><script>function setCaptionSide() {elem = document.querySelector('#caption1');elem.style.captionSide = 'top';}</script></body></html>chevron_rightfilter_noneOutput:
Before clicking the button:

After clicking the button:

- initial: This is used to set this property to its default value.
Example-3:
<!DOCTYPE html><html><head><title>DOM Style captionSide Property</title><style>th,td {border: 2px solid black;padding: 10px;margin: 10px;}#caption1 {caption-side: bottom;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style captionSide Property</b><table><captionid="caption1">List of books</caption><tr><th>Book</th><th>Author</th><th>Price</th></tr><tr><td>Head First Java</td><td>Bert Bates, Kathy Sierra</td><td>500</td></tr><tr><td>Introduction to Algorithms</td><td>CLRS</td><td>1000</td></tr></table><buttononclick="setCaptionSide()"style="margin-top: 10px">Set captionSide</button><!-- Script to set captionSide to initial --><script>function setCaptionSide() {elem = document.querySelector('#caption1');elem.style.captionSide = 'initial';}</script></body></html>chevron_rightfilter_noneOutput:
Before clicking the button:

After clicking the button:

- inherit: This inherits the property from its parent.
Example-4:
<!DOCTYPE html><html><head><title>DOM Style captionSide Property</title><style>th,td {border: 2px solid black;padding: 10px;margin: 10px;}#parent {caption-side: bottom;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style captionSide Property</b><divid="parent"><table><captionid="caption1"style="caption-side: top">List of books</caption><tr><th>Book</th><th>Author</th><th>Price</th></tr><tr><td>Head First Java</td><td>Bert Bates, Kathy Sierra</td><td>500</td></tr><tr><td>Introduction to Algorithms</td><td>CLRS</td><td>1000</td></tr></table></div><buttononclick="setCaptionSide()"style="margin-top: 10px">Set captionSide</button><!-- Script to set captionSide to inherit --><script>function setCaptionSide() {elem = document.querySelector('#caption1');elem.style.captionSide = 'inherit';}</script></body></html>chevron_rightfilter_noneOutput:
Before clicking the button:

After clicking the button:

- Google Chrome
- Internet Explorer 9.0
- Firefox
- Opera
- Apple Safari
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style animationTimingFunction Property
- HTML | DOM Style textDecorationStyle Property
- HTML | DOM Style cursor Property
- HTML | DOM Style animationDirection Property
- HTML | DOM Style visibility Property
- HTML | DOM Style transitionProperty Property
- HTML | DOM Style isolation Property
- HTML | DOM Style clear Property
- HTML | DOM Style filter Property
- HTML | DOM Style columnFill Property
- HTML | DOM Style objectFit Property
- HTML | DOM Style borderBottomColor Property
- HTML | DOM Style opacity Property
Supported Browsers: The browser supported by captionSide property are listed below:
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



