Tutorialspoint.dev

HTML | DOM writeln() Method

This method is used to write a document with addition property of newline character after each statement. This method is similar to 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 order of occurrence.

Example:

<!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>

Output:

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

  • Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter