Javascript Reference - HTML DOM writeln() Method








The writeln() method outputs content as the write() method and adds a newline character.

Syntax

document.writeln(exp1,exp2,exp3,...)

Parameter

Parameter Description
exp1,exp2,exp3,... Optional. What to write to the output stream.

Browser Support

writeln Yes Yes Yes Yes Yes




Example

The following code shows how to use write() and writeln() methods.


<!DOCTYPE html>
<html>
<body>
<pre>
<script>
    document.write("A");
    document.write("B");
</script><!--   w w w  .  j ava2 s. c  o  m-->
</pre>

<pre>
<script>
    document.writeln("C");
    document.writeln("D");
</script>
</pre>

</body>
</html>

The code above is rendered as follows: