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:

  • It is used to return the content property:
    metaObject.content 
  • It is used to set the content property:
    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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <meta name="keywords"
        content="Meta Tags, Metadata" /> 
</head
  
<body
    <center
        <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() { 
                var x = 
                document.getElementsByTagName( 
                "META")[0].content; 
                  
                document.getElementById( 
                "sudo").innerHTML = x; 
            
        </script
</center
</body
  
</html>             

chevron_right


Output:
Before Clicking On Button:

After Clicking On Button:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <meta name="keywords"
        content="Meta Tags, Metadata" /> 
</head
  
<body
    <center
        <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() { 
                var x = 
                document.getElementsByTagName( 
                "META")[0].content = "Hello GeeksForGeeks"
                
                  
                document.getElementById( 
                "sudo").innerHTML = x; 
            
        </script
</center
</body
  
</html>

chevron_right


Output:
Before Clicking On Button:

After Clicking On Button:

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

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

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.