Control the placement of the table caption with CSS

JavascriptWeb DevelopmentFront End Scripts

The CSS caption-side property is used to control the placement of the table caption.

Example

You can try to run the following code to implement caption-side property:

<html>
   <head>
      <style>
         caption.top {
            caption-side:top
         }
         caption.bottom {
            caption-side:bottom
         }
      </style>
   </head>
   <body>
      <table style = "width:500px; border:3px solid gray;">
         <caption class = "top">
            Countries (Top Caption)
         </caption>
         <tr><td> India</td></tr>
         <tr><td> UK</td></tr>
         <tr><td> US</td></tr>
         <tr><td> Australia</td></tr>
      </table>
      <br />
      <table style = "width:500px; border:3px solid blue;">
         <caption class = "bottom">
            Countries (Bottom caption)
         </caption>
         <tr><td> India</td></tr>
         <tr><td> UK</td></tr>
         <tr><td> US</td></tr>
         <tr><td> Australia</td></tr>
      </table>
      <br />
   </body>
</html>
raja
Published on 17-Apr-2018 07:31:40
Advertisements