HTML DOM console log() Method Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The console.log() method in HTML is used for writing a message in the console. It indicates an important message during the testing of any program. The message is sent as a parameter to the console.log() method. Syntaxconsole.log( message )ParametersParameterDescriptionmessageIt is mandatory and used to specify the information to be written on the console. HTML DOM console log() Method ExamplesExample 1: In This example we demonstrates the use of the DOM console.log() method. Clicking the button triggers a function that logs a message to the browser console, allowing developers to view it by pressing F12 or inspecting the page. html <!DOCTYPE html> <html> <head> <title>DOM console.log() Method</title> </head> <body> <h1>GeeksforGeeks</h1> <h2> DOM console.log() Method </h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <p> To view the message, click the button below: </p> <br> <button onclick="log_console()"> View Message </button> <script> function log_console() { console.log("GeeksforGeeks is a portal for geeks."); } </script> </body> </html> Output:Example 2: In this example, we showcases the DOM console.log() method. Clicking the button triggers a JavaScript function, logging an object containing product information to the console for viewing. html <!DOCTYPE html> <html> <head> <title>DOM console.log() Method</title> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.log( ) Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <p> To view the message, click the button below: </p> <br /> <button onclick="log_console()"> View Message </button> <script> function log_console() { let MyElement = { Product: "Coca Cola", Type: "Beverage", }; console.log(MyElement); } </script> </body> </html> Output:Supported Browsers: Google ChromeEdge Internet Explorer Firefox OperaSafari Comment More infoAdvertise with us S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM images Collection Property The images collection property in HTML is used to return the collection of <img> elements in the document. It can be used for knowing the count of images inserted in the document using the <img> tag. The <input> elements with type = image are not counted in the image property.Synta 4 min read HTML DOM console group() Method The console.group() method in HTML is used to create a group of messages in the console. It indicates the start of a message group and all the messages written after calling the console.group() method will write inside the message group. The label is sent as an optional parameter to the console.grou 2 min read HTML DOM console.assert( ) Method The console.assert() method in HTML is used to write a message for the user on the console only if the expression evaluates to false. The expression and the message are sent as parameters to the console.assert() method. Syntax:console.assert( expression, message )Parameters: This method accepts two 2 min read HTML DOM console.info() Method The console.info() method in HTML is used for writing a message in the console. It indicates an important message about any element or object. The message is sent as a parameter to the console.info() method.Syntax:  console.info( message )Parameters: This method accepts a single parameter message wh 2 min read HTML DOM URL Property The DOM URL property in HTML is used to return a string that contains the complete URL of the current document. The string also includes the HTTP protocol such as ( http://).Syntax:document.URLReturn Value: It returns a string value that represents the full URL of the document. Example: In this exam 2 min read HTML DOM head Property The head property in HTML is used to return the first occurrence of the head if multiple heads in the document. It returns the reference of the head object, which represents the <head> elementSyntax: document.headReturn value: It returns the <head> element of the head object.Example: The 2 min read HTML DOM embeds Collection The DOM embeds collection property in HTML is used to return the collection of all embedded elements. The elements in the collection are sorted that appear in the source code. This property is used for read-only. Syntax: document.embedsProperty: This property contains a value length that returns the 3 min read HTML DOM console warn() Method The console.warn() method is used to write a warning message in the console. So open the console to display the output (warning message). Syntax:console.warn( message )Parameters: This method accepts single parameter message which is mandatory. This parameter is used to hold the warning message. Exa 2 min read HTML DOM console trace() Method This console.trace() method is used to display the trace which represents how the code ended up at a certain point. Syntax:console.trace( label )Parameters: This method accepts a single parameter label. Example: In this example, we will use a console.trace() methodHTML<!DOCTYPE html> <html 2 min read HTML DOM title Property The DOM title property is used to return the title of the HTML document and also used to sets the value of the title in the document. This property is used to specify the information about the title.Syntax: It is used to return the title property document.titleIt is used to set the title property do 2 min read Like