JavaScript multi-line String29 Mar 2025 | 4 min read String manipulation is easy to learn but most difficult to master of it in JavaScript. Earlier, multi-line string was not supported by JavaScript. After 2015, string literals have introduced by ES6 (ECMAScript 6) that supports multi-line string. Now, there are several ways to handle multi-line string. We will discuss these different methods to handle multi-line string one-by-one in this chapter. Following are a couple of ways to work with multi-line string: Method 1It is the simplest way of JavaScript to show the string text in multiple lines. Use the break line tab (<br>) or HTML inside the document.write() function to start the text from the new line. ExampleHere is the practical implementation of multi-line string using JavaScript programming: Copy Code Output When you will execute this code, three text strings will display you on the web that will be divided using the break line tab (<br>) of HTML. This is first line display using JavaScript. This is second line and divided using break line tab of HTML. Now, we again printed another new line. Example 2: Concatenating individual stringIn this example, we will simply print the multi-line string without any line break using JavaScript programming: Copy Code Output When you will execute this code, two text paragraphs will show you on the web that will be divided using the break line tab (<br>) of HTML. TpointTech is a website of technologies, which provides tutorials of different technologies and tools. Here you will get tutorials in detail 'like theory as well as practical implementation. We will try to provide you the best knowledge from our side. 'Student, teachers, and industry professionals can learn from here. Example 3This is a simple example of multi-line text printing using JavaScript programming. In this we have only used HTML <br> tab to break the sentences in multiple line: Copy Code Output When you will execute this code, three paragraphs will display you on the web that will be divided using the break line tab (<br>) of HTML. JavaScript is a programming language that is popular for web development at the client-side execution. This language is very light-weighted mostly used to put validations, so they check at client-side. Nowadays, it is very trending in market for web development. As it also allows dynamic execution of code. Method 2: You can also pass the text string inside <p> or <b> or heading tabs (<h1> to <h6>) to divide them into multiple lines or paragraphs. See the code below: Copy Code Output The above-passed line will show in multiple new lines. These lines are started from a new line using the paragraph and bold tab. This is first line of the paragraph. This text will show you in bold letters in next line. Now, it is again a simple text line. Method 3: In this method, we will print a multi-line string. This mostly comes into work when you want to write paragraph writing. Example You can write multi-line text text inside multiple HTML tabs for clear understanding of paragraph. See with help of an example: Copy Code Output An output will display you on the web by executing the above. See the response below; you will see a Display Multiline button to show you a text string. ![]() Click this Display Multiline button and a text string will display you in multiple lines. See the output below: ![]() Next TopicAnonymous-function-in-javascript |
The unique feature of async generator functions in javascript is their support to both await and yield. It returns an async iterator rather than a promise or iterator. The async generator functions are distinct from async functions and the generator functions in javascript. The () function...
3 min read
Window.location is used to provide a Location object with details about the document's current location. This Location object reflects the location (URL) of the object it's linked to, i.e., it holds information about the current content location (host, href, etc.) JavaScript Location Object The window.location attribute represents...
8 min read
? There are many ways to call a JavaScript function in the HTML document, and it is also not a difficult task. First, we have used one of the easiest ways to call a JavaScript function in HTML document: In this method, we will create and define...
3 min read
The ECMAScript6 (ES6) provides the string repeat() feature to repeat the given string. The string can provide data to display the required time with function and event. The repeat method does not affect the original data, but displays require time the similar data. In other words,...
4 min read
The ability to track DOM tree modifications is provided via the MutationObserver interface. It is intended to take the place of the ious Mutation Events functionality, which was included in the DOM3 Events definition. The DOM can often change in complex web projects. Because of this,...
7 min read
We will investigate the CAPS LOCK key and the use of JavaScript on a webpage to determine if it is activated or not. When dealing with cutting-edge online apps, we frequently need specific data, such as user experience and interaction. When a user browses a website,...
4 min read
Javascript logical assignment operators help to use the logical operators with the default and another expression. It works between two expressions or values with a single operator. ES2021 provides three logical assignment operators, which are as follows: Logical AND assignment operator Logical OR assignment operator Nullish coalescing assignment...
5 min read
? A checkbox is a selection box that allows the users to make the binary choice (true or false) by checking and unchecking it. Basically, a checkbox is an icon, which is frequently used in GUI forms and application to get one or more inputs from...
5 min read
? In this article, we will see how to calculate the perimeter and area of a circle using JavaScript. The mathematical formula for calculating the perimeter and area of the circle is given below: Area of circle = π * r * r Perimeter of circle = 2...
1 min read
A collection of properties is stored in an object. In an object, there is an association of a name, also called a key and a value combined with called key and value pairs. But then, external dependency is not required by it when it refers to...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India