# How to hide a DOM element using plain JavaScript

> Learn how to hide a DOM element with plain JavaScript by setting its style.display property to none, then show it again with block or inline.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-11-20 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-hide-element/

How do you hide a DOM element using plain [JavaScript](https://flaviocopes.com/javascript/)?

Every element exposes a `style` property which you can use to alter the CSS styling properties.

You can set the `display` property to 'none' (like you would do in CSS, `display: none;`):

```js
element.style.display = 'none'
```

To display it again, set it back to `block` or `inline`:

```js
element.style.display = 'block'
```
