Table of Contents
- Breaking string using an Escape sequence
- New line using Template literals
- HTML Break Element
- Other Related Concepts
New Line using Template LiteralsTemplate literals sound quite fancy, but underneath the jargon, they are just string literals that allow embedded expressions. This makes it easy to use multi-line strings. We do not enclose template literals with single or double quotes but rather with backtick (` `).
In both cases, the same output is returned. but as you can see Template Literals make it quite simple to write multi-line strings.
HTML Break elementAdding HTML line break elements to your string is another method i haveseen being used quite often. Though break elements must be used where the division of a line must be significat, since this method is quite common we look at it as well.
Note: Remember to use the .innerHTML and not .innerText as you would with other text content.