/

HTML / CSS / JavaScript Tutorial

CSS Property: caption-side

[this page | pdf | back links]

The CSS (CSS2) caption-side property indicates where a table caption should be placed.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

bottom

Puts caption below table

top

(default value). Puts caption above table

 

Default Value:

top

JavaScript syntax:

e.g. object.style.captionSide="bottom"

Inherited:

Yes

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td {border: thin solid red}
table.x1 {caption-side: bottom;}
</style>
<link rel="stylesheet" type="text/css" href="Content\ExampleStyles.css">
</head>
<body>
<table>
  <caption>1. Element with default property</caption>
  <tr><td>&nbsp;</td></tr>
</table>
<br>
<table class="x1">
  <caption>2. Element set using in-file HTML style</caption>
  <tr><td>&nbsp;</td></tr>
</table>
<br>
<table id="x2">
  <caption>3. Element set using JavaScript</caption>
  <tr><td>&nbsp;</td></tr>
</table>

<script>
document.getElementById("x2").style.captionSide = "bottom";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyCaptionSide() {
  var x = document.createElement("DIV"); x.style.captionSide = "bottom"; return (window.getComputedStyle(x, null).captionSide == "bottom");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile