Create a text node:
The result will be:
HTML elements often consists of both an element node and a text node.
To create a header (H1), you must create both an "H1" element and a text node:
Create a header:
The result will be:
The createTextNode() method creates a Text Node with the specified text.
![]()
The createTextNode() method is supported in all major browsers.
| Parameter | Type | Description |
|---|---|---|
| text | String | Required. The text of the Text node |
| Type | Description |
|---|---|
| Text Node object | The created Text node |
| DOM Version | Core Level 1 |
|---|
Your message has been sent to W3Schools.