Move the table caption to the bottom of the table:
document.getElementById("myCap").style.captionSide = "bottom";
Click the button to change the caption-side property of the CAPTION element:
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>// ww w . j a va2s. c o m </head> <body> <button onclick="myFunction()">Test</button> <table> <caption id="myCap">Table 1.1 Customers</caption> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>CSS</td> <td>A</td> <td>G</td> </tr> <tr> <td>HTML</td> <td>B</td> <td>S</td> </tr> <tr> <td>Java</td> <td>C</td> <td>M</td> </tr> </table> <script> function myFunction() { document.getElementById("myCap").style.captionSide = "bottom"; } </script> </body> </html>
The captionSide property sets or gets the position of the table caption.
Property Values
Value | Description |
---|---|
top | Default . Positions the table caption above the table |
bottom | Positions the table caption below the table |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
The captionSide property returns a String representing the position of the table caption.