---
title: DOM Methods
description: "> HTML DOM methods are **actions** you can perform (on HTML Elements). > > > > HTML DOM properties are **values** (of HTML Elements) that you can set or change. --- ## The DOM Programming Interface The HTML DOM can be accessed with JavaScript…"
url: "https://apprentice.mn/docs/dom-methods/"
updated: "2021-05-19"
category: Javascript
---

# DOM Methods

> HTML DOM methods are **actions** you can perform (on HTML Elements).
>
>
>
> HTML DOM properties are **values** (of HTML Elements) that you can set or change.

---

## The DOM Programming Interface

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

In the DOM, all HTML elements are defined as **objects**.

The programming interface is the properties and methods of each object.

A **property** is a value that you can get or set (like changing the content of an HTML element).

A **method** is an action you can do (like add or deleting an HTML element).

---

## Example

The following example changes the content (the `innerHTML`) of the `<p>` element with `id="demo"`:

### Example

      `<html>
<body>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>

</body>
</html>`

In the example above, `getElementById` is a **method**, while `innerHTML` is a **property**.

---

## The getElementById Method

The most common way to access an HTML element is to use the `id` of the element.

In the example above the `getElementById` method used `id="demo"` to find the element.

---

## The innerHTML Property

The easiest way to get the content of an element is by using the `innerHTML` property.

The `innerHTML` property is useful for getting or replacing the content of HTML elements.

The `innerHTML` property can be used to get or change any HTML element, including `<html>` and `<body>`.

         [https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods](https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods)[https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods](https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods)[https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods](https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2Fdom-methods%2F&linkname=DOM%20Methods)[https://www.addtoany.com/share](https://www.addtoany.com/share)
