HTML | DOM Meta Object
The DOM Meta Object is used to represent the HTML <meta> element. The Meta element is accessed by getElementById().
Properties:
- Name attribute: This attribute is used to define the name of property.
- http-equiv attribute: This attribute is used to get http response message header.
- Scheme attribute: This attribute is used to specify a scheme to interpret the property’s value.
- Content attribute: This attribute is used to specify properties value.
Syntax:
document.getElementById("ID");
Where “id” is the ID assigned to the “meta” tag.
Example-1:
<!DOCTYPE html> <html> <head> <meta name="keywords" content="Meta Tags, Metadata" /> </head> <body> <center> <h1>GeeksForGeeks</h1> <h2>DOM Meta Object</h2> <p>Hello GeeksforGeeks!</p> <button onclick="myGeeks()"> Submit</button> <p id="sudo"></p> <script> function myGeeks() { var x = document.getElementsByTagName( "META")[0].content; document.getElementById( "sudo").innerHTML = x; } </script> </center> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Example-2: Meta Object can be created by using thedocument.createElement Method.
<!DOCTYPE html> <html> <head> <title>DOM Meta Object </title> </head> <body> <center> <h1>GeeksForGeeks</h1> <h2>DOM Meta Object</h2> <p>Hello GeeksforGeeks!</p> <button onclick="myGeeks()"> Submit</button> <p id="sudo"></p> <script> function myGeeks() { // meta tag created var g = document.createElement("META"); g.setAttribute("name", "keywords"); g.setAttribute("content", "Meta Tags, Meta data"); document.head.appendChild(g); document.getElementById("sudo").innerHTML = "HTML DOM Meta Object created."; } </script> </body> </html> |
Output:
Before Clicking On Button :

After Clicking On Button:

Supported Browsers: The browser supported by DOM Meta Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <Meta> Tag
- How to use Meta Tag to redirect an HTML page?
- HTML | <meta> charset Attribute
- HTML | <meta> content Attribute
- HTML | Viewport meta tag for Responsive Web Design
- HTML | DOM Object Object
- HTML | Object tag
- HTML | DOM Div Object
- HTML | DOM Bdo Object
- HTML | DOM DD Object
- HTML DOM Aside Object
- HTML | DOM dl Object
- HTML | DOM Ol Object
- HTML | DOM li Object
- HTML | DOM DT Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

