Skip to main content
all property

[all is no longer supported. Starting with Internet Explorer 11, use getElementById. For info, see Compatibility changes.]

Returns a reference to the collection of elements contained by the object.



p = object.all


Property values

Type: Object

Array of elements contained by the object.

Standards information

There are no standards that apply here.


The all collection includes one element object for each valid HTML tag. If a valid tag has a matching end tag, both tags are represented by the same element object.

The collection returned by the document's all collection always includes a reference to the HTML, HEAD, and TITLE objects regardless of whether the tags are present in the document. If the BODY tag is not present, but other HTML tags are, a BODY object is added to the all collection.

If the document contains invalid or unknown tags, the collection includes one element object for each. Unlike valid end tags, unknown end tags are represented by their own element objects. The order of the element objects is the HTML source order. Although the collection indicates the order of tags, it does not indicate hierarchy.

The name property only applies to some elements such as form elements. If the vIndex is set to a string matching the value of a name property in an element that the name property does not apply, then that element will not be added to the collection.


This example, in JScript (compatible with ECMA 262 language specification), shows how to display the names of all tags in the document in the order the tags appear in the document.

for(i = 0; i < document.all.length; i++){

This example, also in JScript, shows how to use the item method on the all collection to retrieve all element objects for which the name property or ID attribute is set to sample. Depending on the number of times the name or ID is defined in the document, the item method returns null, a single element object, or a collection of element objects. The value of the length property of the collection determines whether item returns a collection or a single object.

var oObject = document.all.item("sample");
if (oObject != null){
   if (oObject.length != null){
      for (i = 0; i < oObject.length; i++){