HTML DOM console table() Method Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The console.table() method in HTML is used for writing data in tabular form in the console view. The table data is sent as a parameter to the console.table() method which must be an object or an array containing the data to be filled in the table. Syntax:console.table( tabledata, tablecolumns );Parameters: This method accepts two parameters as mentioned above and described below:tabledata: It is a mandatory parameter that specifies the information to be written in the table.tablecolumns: It is an optional parameter that specifies the names of the columns included in the table.Example 1: The below program illustrates the console.table() method in HTML: HTML <!DOCTYPE html> <html> <head> <title>DOM console.table( ) Method in HTML</title> <style> h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.table( ) Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <p> To view the message, double click the button below: </p> <br> <button ondblclick="table_console()"> View Table </button> <script> function table_console() { console.log ("GeeksforGeeks offers the following courses :"); console.table (["fork python", "fork cpp", "fork java"]); } </script> </body> </html> Output: Example 2: Using an array of objects with the console.table() method. html <!DOCTYPE html> <html> <head> <title>DOM console.table( ) Method in HTML</title> <style> h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.table() Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <script> let Product1 = { Product: "Coca Cola", Type: "Beverage" } let Product2 = { Product: "Lays", Type: "Potato Wafers" } let Product3 = { Product: "Walnut Brownie", Type: "Dessert" } let Product4 = { Product: "KitKat", Type: "Chocolate" } console.table ([Product1, Product2, Product3, Product4]); </script> </body> </html> Output: Example 3: Displaying only specific columns with the console.table() method html <!DOCTYPE html> <html> <head> <title>DOM console.table( ) Method in HTML</title> <style> h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.table( ) Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <script> let Product1 = { Product: "Coca Cola", Type: "Beverage" } let Product2 = { Product: "Lays", Type: "Potato Wafers" } let Product3 = { Product: "Walnut Brownie", Type: "Dessert" } let Product4 = { Product: "KitKat", Type: "Chocolate" } console.table ([Product1, Product2, Product3, Product4], ["Product"]); </script> </body> </html> Output:Supported Browsers: The browsers are supported by the console.table() Methods are listed below:Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us Next Article HTML DOM console table() Method S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM activeElement Property The DOM activeElement property is used to return the currently active elements in the HTML document. This property is read-only. It gives the reference of a focused element object in the document. Syntax: document.activeElementReturn Value: A reference to the element object in the document that has 2 min read HTML DOM anchors Collection The HTML DOM anchors collection is used to return the collection of all <a> elements. It only counts those <a> element that has the name attribute only. The name attribute of the anchor element does not support HTML 5. The elements in the collection are sorted that appear in the source c 2 min read HTML DOM close() Method The DOM close() method is used to close the output stream. It is used to indicate the finish of writing on a window. The close() method does not require any parameter. Syntax:document.close()Example 1: In this example, we will use DOM close() method.HTML<!DOCTYPE html> <html> <head 2 min read HTML DOM baseURI Property The DOM baseURI property is used to return the base Uniform Resource Identifier (URI) of the document. This property is used for read-only. This property returns a string value that represents the base URI of the page.Syntax: node.baseURIReturn Value: It returns a string value that represents the UR 2 min read HTML DOM body Property The HTML DOM Body property is used to set the document <body> element. It only returns the content present in the <body> Tag. This property is used to change the present content inside the <body> element and sets them with the new specified content. This property does not return th 2 min read HTML DOM createAttribute() Method This createAttribute() method is used to create an attribute with the specified name and returns the attribute object. The attribute.value property is used to set the value of the attribute and the element.setAttribute() method is used to create a new attribute for an element. This method() contains 2 min read HTML DOM doctype Property The DOM doctype property is used to return the doctype of any HTML document. The DocumentType object is the name property used to return the name of the object. If there is no doctype declared in the document then it returns a Null value. Syntax:document.doctypeExample: In this example, we will use 2 min read HTML DOM writeln() Method The writeln() method is used to write a document with the additional property of a newline character after each statement. This method is similar to the document.write() method. Syntax: document.writeln( exp1, exp2, exp3, ... )Parameters: This method contains many parameters which are optional. All 1 min read HTML DOM console error() Method The console.error() method in HTML is used to display an error message on the console. The console.error() method is used for testing purposes. The error message is sent as a parameter to the console.error() method. Syntax:console.error( message )Parameters: This method accepts a single parameter me 2 min read HTML DOM console groupCollapsed() Method The console.groupCollapsed() method in HTML is used to create a collapsed group of messages in the console. It indicates the start of a collapsed message group and all the messages written after calling the console.groupCollapsed() method will write inside the message group. The label is sent as an 2 min read Like