---
title: "Discussion on \"How would you create a new h1 element with javascript?\" | Hashnode"
description: "Discussion on \"How would you create a new h1 element with javascript?\". First, I would check if the element already exists. If it doesn't I will create the element and add it to the DOM tree.\nIf ( document .querySelector( '#title' )) { } else { var title = document .createElement( 'h1' ); title.innerHTML = 'New Heading' ..."
url: "https://hashnode.com/posts/how-would-you-create-a-new-h1-element-with-javascript/614ed12894bb297e1aad6451"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How would you create a new h1 element with javascript?](https://wpsyed.hashnode.dev/how-would-you-create-a-new-h1-element-with-javascript?utm_source=hashnode&utm_medium=feed)

First, I would check if the element already exists. If it doesn't I will create the element and add it to the DOM tree. If ( document .querySelector( '#title' )) { } else { var title = document .createElement( 'h1' ); title.innerHTML = 'New Heading' ...

Sep 25, 2021 · 2 min read · wpsyed.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#element-queries](https://hashnode.com/tag/element-queries)

## Written by

[Syed](https://hashnode.com/@SyedSaadullah)

@SyedSaadullah · Pakistan

  
[View profile](https://hashnode.com/@SyedSaadullah)

I help people to get more results for their businesses using WordPress.

I am a WordPress Developer from Pakistan. Having more then 5 years of experience right on the edge of dev. Build ultra fast WordPress sites.

## Responses 2

Markdown supported · ⌘↵ to post

[ScholorshipOwl](https://hashnode.com/@jpsteven)

[Apr 13, 2022](https://hashnode.com/posts/how-would-you-create-a-new-h1-element-with-javascript/614ed12894bb297e1aad6451/comment/6257047ce58c4ac41a6757cd)

[Laptopsea](https://laptopsea.com/)

[Syed](https://hashnode.com/@SyedSaadullah)

[Oct 3, 2021](https://hashnode.com/posts/how-would-you-create-a-new-h1-element-with-javascript/614ed12894bb297e1aad6451/comment/6159e94ce2f1936f70b2850e)

if you have any questions then please feel free to ask! I would also appreciate it if you mind checking my [techcomputerinfo.com](https://hashnode.com/posts/how-would-you-create-a-new-h1-element-with-javascript/techcomputerinfo.com) Computerinfo based website.
