Attributes are the values ​​of nodes (HTML elements) that you can get or set.

HTML DOM attributes syntax

The HTML DOM can be accessed through JavaScript (and other programming languages).

All HTML elements are defined as objects, and the programming interface is object methods and object properties.

Methods are actions you can perform (such as adding or modifying elements).

Attributes are values ​​that you can get or set (such as the name or content of a node).

HTML DOM attributes example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>

<p id="intro">Hello World!</p>

<script>
var txt=document.getElementById("intro").innerHTML;
document.write(txt);
</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance