DEV Community

Cover image for How to get all the HTML tags from a website using JavaScript?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

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

Originally posted here!

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("*");
Enter fullscreen mode Exit fullscreen mode
  • 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 😃.


Top comments (0)