JavaScript document.getElementsByTagName enables you to access the HTML elements by their Tag names. getElementsByTagName method returns the collection of HTML elements placed inside the HTML body tag. You can pass the wildcard character "*" to get the collection of all HTML elements or you can specifiy the HTML tag name e.g.: DIV, SPAN, P etc. whose collection you want to retrieve.
Try the sample below to learn and practice the document.getElementsByTagName method and loop over the collection of elements to access their properties: