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

6

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)

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay