br enclosed between 2 brackets < > enclosed in double quotation marks, and preceded and followed by the + sign:
USE JS to insert a line break into HTML?
The example of concatenated 2 strings, display in one <p> tag. To break line using a br tag.
<!DOCTYPE html> <html> <body> <p id="c1"></p> <p id="c2"></p> <script> // strings var str1 = "EyeHunts"; var str2 = "Next Line" document.getElementById("c1").innerHTML = str1 + "<br>" + str2; </script> </body> </html>
Js break line in Alert box
In the alert box, you can use “\n”, to break the sentence into a new line.
\n escape sequence.
Note: The All JS Examples codes are tested on Safari browser (Version 12.0.2) and Chrome.
OS: macOS 10.14 Mojave
Code: HTML 5 Version
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.