Open In App

HTML DOM Meta name Property

Last Updated : 16 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML DOM Meta name Property is used for returning or setting the name of the name and it is used to reference form data when it has been submitted by the user. It also refers to the element in the javascript. 

Syntax: 

  • It is used to return the name property.
metaObject.name
  • It is used to set the name property.
metaObject.name = name

Property Values:

  • name: It specifies the name of the Meta Element.

Return Value: It returns a string value that represents the name of the Meta Element. 

Example 1: This program illustrates how to return the name Property. 

HTML




<!DOCTYPE html>
<html>
   
<head>
    <meta name="keywords"
          content="Meta Tags, Metadata" />
</head>
   
<body>
    <h1>GeeksForGeeks</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello GeeksforGeeks!</p>
    <button onclick="myGeeks()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            let x = document.getElementsByTagName(
                    "META")[0].name;
            document.getElementById(
                "sudo").innerHTML = x;
        }
    </script>
</body>
   
</html>


Output: 

 

 Example 2: This program illustrates how to set the name Property. 

HTML




<!DOCTYPE html>
<html>
   
<head>
    <meta name="keywords"
          content="Meta Tags, Metadata" />
</head>
   
<body>
    <h1>GeeksForGeeks</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello GeeksforGeeks!</p>
    <button onclick="myGeeks()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            let x = document.getElementsByTagName(
                    "META")[0].name = "Hello Geeks";
            document.getElementById(
                "sudo").innerHTML = x;
        }
    </script>
</body>
   
</html>


Output: 

 

Supported Browsers: The browsers supported by DOM Meta name Property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads