How to Create a New Line in JavaScript ? Last Updated : 09 Nov, 2024 Comments Improve Suggest changes Like Article Like Report A new line can be made in JavaScript using the below-discussed methods.Using Escape Sequence `\n`The \n escape sequence represents a newline character in JavaScript strings and it can used to render a new line in JavaScript. JavaScript console.log("GfG"); console.log("\n"); // New line console.log("Courses\n"); // New Line With Text console.log("Learn"); console.log("\n\n"); // Two New Lines console.log("Grow"); Using ECMAScript6 (ES6) template literalsIn ECMAScript6, the backticks (``) are used to create a template literal. Template literals can span multiple lines without the need for escape characters, making it easier to write and read multiline strings in JavaScript.Example: The below code uses the ES6 template literals to add a new line in JavaScript. JavaScript console.log(`Q: What is GfG? A: GeeksforGeeks`); Using Empty Call of console.log() The console.log() method is a part of the JavaScript Console API, which provides methods for interacting with the browser's console. It also returns a new line when the method is called and utilized so this approach can be used in place of an escape character.Example: The below code uses the console.log() method to add a new line in JavaScript. JavaScript console.log('GFG'); console.log(); console.log('GeeksforGeeks'); OutputGFG GeeksforGeeks In document.write() The document.write() method is a part of the JavaScript Document Object Model (DOM) API. It is used to dynamically write content to a document, specifically the HTML document. This method is especially useful if a new line has to be added or rendered on an HTML page using the <br> tag.Example: The below code uses the document.write() method to add a new line in an HTML document using JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML Document</title> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <script src="./script.js"></script> </body> </html> JavaScript document.write ("A computer science portal"); document.write ("<br>"); document.write ("for geeks."); Output:Using JavaScript document.writeln() MethodThis method is especially useful if a new line has to be added to an HTML page. The only difference between this method and document.write() is that the document.writeln() automatically adds a new line after the rendered content instead of adding the <br> tag as done in the previous approach.Example: The below code uses the document.writeln() method to add a new line in an HTML document using JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>HTML Document</title> </head> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <!-- JavaScript --> <script> document.writeln ("A computer science"); document.writeln ("portal for geeks."); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Create a New Line in JavaScript ? R rajatsandhu2001 Follow Improve Article Tags : JavaScript Web Technologies Geeks Premier League JavaScript-Questions Geeks Premier League 2023 +1 More Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Steady State Response In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We 9 min read JavaScript Interview Questions and Answers JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. Both front-end and back-end developers need to have a strong command of JavaScript, as 15+ min read React Tutorial React is a JavaScript Library known for front-end development (or user interface). It is popular due to its component-based architecture, Single Page Applications (SPAs), and Virtual DOM for building web applications that are fast, efficient, and scalable.Applications are built using reusable compon 8 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Like