Open In App

HTML DOM Meta content Property

The Meta content Property in HTML DOM is used for setting or returning the value of the content attribute of a <meta> element. The content attribute is used to specify the content of the meta-information. 

Syntax:



metaObject.content 
metaObject.content = text

Property Values: It contains the value i.e. text which defines the content of the meta information. 

Return Value: It returns a string value that represents the value of the content attribute of the meta element. 



Example: In this example, we will see the use of Meta content Property




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

Output: 

 

 Example 2: In this example, we will see the use of Meta content Property




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

Output:   

 

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


Article Tags :