+ 1

Needing Help javascript

How can i use new line and new tab in my code ( \n and \t )

31st Mar 2020, 11:19 PM
AHMAD AMIRU
AHMAD AMIRU - avatar
1 Resposta
+ 2
console.log() and alert() make use of standard new line and tab char... however, if your purpose is to output them inside the document (web page), you must know that html collapse all spaces (new line and tabs are converted to simple space) by default. To insert a new line, you can use the <br> html element, and for tabs you need some css... or you need to output in an element with the css property 'white-space' set to 'pre' or 'pre-wrap' (or use the <pre></pre> element wich is set by dedault to format plaintext as is -- without collapsing spaces)
1st Apr 2020, 3:12 AM
visph
visph - avatar