0

Can we use \n \t (escape characters ) in document.write() method?

2nd Jan 2017, 3:21 PM
Satya Rohit
Satya Rohit - avatar
2 Respostas
+ 3
No. document.write() will not allow \n or \t as escape characters. It will throw error instead. Uncaught SyntaxError: Invalid or unexpected token.
25th Jan 2017, 5:40 PM
Vipul Pathe
Vipul Pathe - avatar
+ 1
Nope. They won't be translated into HTML. If you want to create newlines in your page, better to use "<br/>", as seen here. Since there are no tabs in HTML, you'll need to create a class in CSS, and reference it in your string. Alternatively, you *might* be able to use x number of &nbsp; in succession, although I'm not sure that will work either.
4th Jan 2017, 2:03 PM
Mike L.
Mike L. - avatar