HTML | DOM Table createCaption( ) Method Last Updated : 20 Nov, 2021 Comments Improve Suggest changes Like Article Like Report The Table createCaption() method is used in a table to create <caption> which is empty. It doesn't work if there is already a <caption> element. In such a case, the createCaption() method returns the existing one.Syntax tableObject.createCaption()Return Value : The newly created (or an existing) <caption> element Below program illustrates the Table createCaption() method : Example-1: Creating a <caption> element. html <!DOCTYPE html> <html> <head> <title>Table createCaption() Method in HTML</title> <style> table, td { border: 1px solid green; } h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Table createCaption() Method</h2> <p>To create a Caption for the table, double-click the "Add Caption" button. </p> <table id="Courses" align="center"> <tr> <td>Java</td> <td>Fork Java</td> </tr> <tr> <td>Python</td> <td>Fork Python</td> </tr> <tr> <td>Placements</td> <td>Sudo Placement</td> </tr> </table> <br> <button ondblclick="Add_Caption()"> Add Caption </button> <script> function Add_Caption() { // Creating caption. var MyTable = document.getElementById( "Courses").createCaption(); // Caption value. MyTable.innerHTML = "<strong>GeeksforGeeks</strong>"; } </script> </body> </html> Output:Before clicking the button: After clicking the button: Supported Browsers: Apple SafariInternet ExplorerFirefoxGoogle ChromeOpera Comment More infoAdvertise with us Next Article HTML | DOM Table createCaption( ) Method S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM Table deleteCaption() Method The Table deleteCaption() method is used for deleting a <caption> element and removing its content from the table. It can be only used if a <caption> element already exists. Syntax:tableObject.deleteCaption()Example: In this example, delete table caption element using tableObject.deleteC 1 min read HTML | DOM Table createTFoot( ) Method The Table createTFoot() method is used for creating an empty <tfoot> element and adding it to the table. It does not create a new <tfoot> element if a <tfoot> element already exists. In such a case, the createTFoot() method returns the existing one. The <tfoot> element must h 2 min read HTML | DOM Table createTHead() Method The Table createTHead() method is used for creating an empty <thead> element and adding it to the table. It does not create a new <thead> element if a <thead> element already exists. In such a case, the createThead() method returns the existing one . The <thead> element must 2 min read HTML | DOM Table caption Property The Table caption property returns the <caption> element of a table which is used to define the caption for a table. Only one caption can be assigned to a table and the caption entered inside the <caption> element is center aligned by default. Syntax tableObject.caption Return Value: It 2 min read HTML DOM Table rows Collection The Table rows collection is used for returning the collection of all the <tr> elements in a table. The sequence of the <tr> elements is sorted in the same way as their position in the source code. SyntaxtableObject.rowsProperties:length: It returns the number of <tr> elements in t 2 min read Like