captionSide style property
8 | ||||
Specifies or returns the position of the caption box within a table element.
Note: The captionSide property is supported in Internet Explorer from version 8.
Earlier versions of Internet Explorer support the align property to provide similar functionality, but that property is deprecated in HTML 4.01.
If you want to align a caption element to the top or bottom side of a table element, use the vAlign property in Internet Explorer earlier than version 8.Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: caption-side |
Possible values:
The type of this property is string.
One of the following values:
Positions the caption box below the table box. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Positions the caption box to the left of the table box. | |||||||
Positions the caption box to the right of the table box. | |||||||
Positions the caption box above the table box. |
Default: top.
Example HTML code 1:
This example illustrates the use of the caption-side property:
|
||||
<head> <style> .example { caption-side: bottom; width: auto; text-align: center; font-weight: bold; } </style> </head> <body> <table> <caption valign="bottom" class="example">Fruits</caption> <tr> <td>Apple</td> <td>13.46</td> </tr> <tr> <td>Pear</td> <td>35.21</td> </tr> <tr> <td>Peach</td> <td>23.12</td> </tr> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the captionSide property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeCaptionSide (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the text of the selected option var selectState = selectTag.options[whichSelected].text; var caption = document.getElementById ("myCap"); if ('captionSide' in caption.style) { caption.style.captionSide = selectState; } else { // Internet Explorer before version 8 caption.align = selectState; } } </script> </head> <body> <table> <caption id="myCap">Fruits</caption> <tr> <td>Apple</td> <td>13.46</td> </tr> <tr> <td>Pear</td> <td>35.21</td> </tr> <tr> <td>Peach</td> <td>23.12</td> </tr> </table> <select onchange="ChangeCaptionSide (this);" size="4"> <option selected="selected" />bottom <option />left <option />right <option />top </select> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.runtimeStyle, htmlElement.style
HTML elements:
Related pages:
External links:
caption-side (MSDN)
caption-side (Mozilla Developer Center)
caption-side (Safari Reference Library)
caption-side (W3C)
caption-side (Mozilla Developer Center)
caption-side (Safari Reference Library)
caption-side (W3C)
User Contributed Comments