HTML DOM Meta name Property

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>w3wiki</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello w3wiki!</p>
    <button onclick="myBeginner()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myBeginner() {
            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>w3wiki</h1>
    <h2>DOM Meta name Property</h2>
    <p>Hello w3wiki!</p>
    <button onclick="myBeginner()">
        Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myBeginner() {
            let x = document.getElementsByTagName(
                    "META")[0].name = "Hello Beginner";
            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