Latest web development tutorials
 

Meta content Property

< Meta Object

Example

Return the value of the content attribute of all meta elements:

var x = document.getElementsByTagName("META");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
    txt = txt + "Content of "+(i+1)+". meta tag: "+x[i].content+"<br>";
}

The result of txt will be:

Content of 1. meta tag: Free Web tutorials
Content of 2. meta tag: HTML5,CSS,JavaScript
Content of 3. meta tag: John Doe
Try it Yourself »

Definition and Usage

The content property sets or returns the value of the content attribute of a meta element.

The content attribute specifies the content of the meta information.

Note: The available values of this property depends on the value of the name and the httpEquiv properties.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The content property is supported in all major browsers.


Syntax

Return the content property:

metaObject.content

Set the content property:

metaObject.content=text

Value Description
text The content of the meta information

Return Value

Type Description
String The value of the content attribute of the meta element

More Examples

Example

Change the value of the content attribute of the third meta element (index 2) in head:

document.getElementsByTagName("META")[2].content = "Bill Mosley";
Try it Yourself »

< Meta Object