HTML | DOM writeln() Method

The writeln() method is used to write a document with additional property of newline character after each statement. This method is similar to the document.write() method.

Syntax:

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

Parameters: This method contain many parameters which is optional. All the expression arguments (exp1, exp2, …) can be listed and display with the order of occurrence.



Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>DOM writeln() Method</title>
        <style>
            h1 {
                color:green;
            }
            body {
                text-align:center;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>DOM writeln() Method</h2>
        <pre>
        <script>
            document.write("Hello World!");
            document.write("Have a nice day!");
        </script>
        </pre>
        <pre>
        <script>
            document.writeln("Hello World!");
            document.writeln("Have a nice day!");
        </script>
        </pre>
    </body>
</html>

chevron_right


Output:

Supported Browsers: The browser supported by writeln() method are listed below:

  • Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.