Document: writeln() method
Writes a string of text followed by a newline character to a document.
Syntax
js
writeln(line)
Parameters
line
-
A string containing a line of text.
Return value
None (undefined
).
Examples
js
document.writeln("<p>enter password:</p>");
Notes
document.writeln is the same as document.write
but adds a newline.
Note: document.writeln (like document.write) does not work in XHTML documents (you'll get a "Operation is not supported" (NS_ERROR_DOM_NOT_SUPPORTED_ERR
) error on the error console). This is the case if opening a local file with a .xhtml file extension or for any document served with an application/xhtml+xml MIME type. More information is available in the W3C XHTML FAQ.
Specifications
Specification |
---|
HTML # dom-document-writeln-dev |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
writeln | ||||||||||||
Accepts TrustedHTML instances |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- User must explicitly enable this feature.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.