Element.innerHTML (Property)

The inner HTML of a tag in the document.


JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myElement.innerHTML
-myElement.innerHTML = someHTML
Argument list:someHTMLSome new HTML content to place inside the object

The HTML in between but not including the tags that define the element is extracted. The resulting content complete with tags and text is returned when this property is being read.

When the property is being written to, the start and end tags remain intact but everything between them is replaced with a sequence of HTML content.

This property contains the text and any HTML tags that are contained in the body of the element. If you only want the text, then use the innerText property.

If you want to include the containing tags, then use the outerHTML or outerText properties instead.

You can assign new text to be displayed in the HTML element by using this property as an LValue.

The innerHTML property of an HTML Element object is supported in Netscape 6.0 although it is not mandated in the DOM specification. However Netscape 6.0 does not also support innerText, outerHTML or outerText. You should be able to accomplish what you need with innerHTML though.


See also:Element object, Element.canHaveHTML, Element.innerText, Element.insertAdjacentHTML(), Element.outerHTML, Element.outerText

insert figure 0047