How to get all the HTML tags from a website using JavaScript?

Published January 31, 2021

To get all the HTML tags present in a website using JavaScript, you can use the getElementsByTagName() method in the global document object and then pass the asterisk symbol * as an argument to it.

// Get all HTML tags
const allHTMLTags = document.getElementsByTagName("*");
  • The method returns an array-like object called HTMLCollection which you can also loop to get single tags.

See this example live in JSBin.

Feel free to share if you found this useful 😃.


Share on: Facebook Twitter