I need to create a
tag dynamically with javascript.
var br = document.createElement(\'br\');
And
In reality, your code will still validate if your JavaScript doesn't exactly validate, because the validator only parses the processed HTML code, not the dynamic code created by JavaScript. If you cared, you could also use an innerHTML
trick, or a document.createTextNode('
if you wanted to force the XHTML version, but it is not recommended.
');document.createElement('br');
works perfectly fine.