The following code selects all <p> elements in a document:Example const myCollection = document.getElementsByTagName("p"); The elements in the collection can be accessed by an index number. To access the second <p> element you can write: myCollection[1] Try it Yourself » ...