HTML | DOM Table insertRow( ) Method Last Updated : 20 Nov, 2021 Comments Improve Suggest changes Like Article Like Report The Table insertRow() method is used for creating an empty <tr> an element which can be added to a table. It is generally used for inserting a new row(s) at the specified index in the table. A <tr> element contain atleast one <th> or <td> elements.Syntax tableObject.insertRow(index) Parameters Used index: It is used to specify the position of the row to be inserted. The value 0 results in the insertion of the new row at the first position whereas -1 can be used to insert the new row at the last position. Return Value : It returns the inserted <tr> element Below program illustrates the Table insertRow() method : Example-1: Inserting new row at the first position of a table. html <!DOCTYPE html> <html> <head> <title>Table insertRow() 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 insertRow() method</h2> <p>To add a new row at the first position of the table, double-click the "Add Row" 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> </table> <br> <button ondblclick="row()"> Add Row </button> <script> function row() { var MyTable = document.getElementById("Courses"); // insert new row. var NewRow = MyTable.insertRow(0); var Newcell1 = NewRow.insertCell(0); var Newcell2 = NewRow.insertCell(1); Newcell1.innerHTML = "Placement"; Newcell2.innerHTML = "Sudo Placement"; } </script> </body> </html> Output: After clicking the button Supported Browsers: Apple SafariInternet ExplorerFirefoxGoogle ChromeOpera Comment More info S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM Explore HTML BasicsHTML Introduction5 min readHTML Editors5 min readHTML Basics7 min readStructure & ElementsHTML Elements5 min readHTML Attributes8 min readHTML Headings4 min readHTML Paragraphs5 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists5 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks3 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables10 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics6 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like