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

January 31, 2021 - 1 min read

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 😃.