CSS caption-side Property
CSS caption-side Property
CSS caption-side
property puts the content of a table's <caption>
on the specified side.
Example
<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
table, td, th{
border: 1px solid black;
}
table{
width: 200px;
}
#point{
caption-side: top;
}
#point1{
caption-side: bottom;
}
</style>
</head>
<body>
<h1>CSS caption-side Property</h1>
<h2>caption-side: top;</h2>
<table id="point">
<caption>Table 1.1 User Details</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jos</td>
<td>28</td>
</tr>
<tr>
<td>Alex</td>
<td>34</td>
</tr>
</table>
<h2>caption-side: bottom;</h2>
<table id="point1">
<caption>Table 1.1 User Details</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jos</td>
<td>28</td>
</tr>
<tr>
<td>Alex</td>
<td>34</td>
</tr>
</table>
</body>
</html>
Syntax
Using CSS
element{
caption-side: bottom;
}
Using Javascript
object.style.captionSide="bottom";
Animatable
No, caption-side property is not animatable. CSS Animatable Properties Reference.
Default Value
Default value for CSS caption-side property is top.
Property Value
The following table provides a list of values for CSS caption-side
property.
Value | Explanation |
---|
top | Puts the caption above the table. |
bottom | Puts the caption below the table. |
Using JavaScript
In the following example, we will demonstrate how to change the CSS caption-side
property of an element using JavaScript.
Example
<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
table, td, th{
border: 1px solid black;
}
table{
width: 200px;
}
#point{
caption-side: top;
}
</style>
</head>
<body>
<h1>CSS caption-side Property</h1>
<table>
<caption>Table 1.1 User Details</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jos</td>
<td>28</td>
</tr>
<tr>
<td>Alex</td>
<td>34</td>
</tr>
</table>
<button onclick="myFunction()">Click Me</button>
<script>
var x = document.getElementsByTagName("table")[0];
function myFunction(){
x.style.captionSide = "bottom";
}
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in CSS.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.
Share this Page
Meet the Author