HTML DOM getElementsByTagName() method
Example
Return a collection of objects with the specified tag name:
document.getElementsByTagName("P");
Try it »
Definition and Usage
The getElementsByTagName() method returns a collection of objects with the specified tag name.
Tip: The parameter value "*" returns all elements of the document.
Browser support





All major browsers support the getElementsByTagName() method
Syntax
document.getElementsByTagName(
tagname
)
Parameters
| Parameters | Type | Description |
|---|---|---|
| tagname | String | Required. The tag name of the element you want to get. |
Return Value
| Type | Description |
|---|---|
| NodeList object | A collection of elements with the specified tag name |
Technical Details
| DOM version | Core Level 1 Document Object |
|---|
Document Object