It has been over 14 years since this piece of junk hit the internet, thanks to Internet Explorer (version 4). Many newer designers and developers have probably never encountered this JavaScript selector, but will no doubt pop up eventually. I was shocked to find this selector is use today in a script for an enterprise application I was working with.

Solid Statement: Don’t even think about using document.all. Only use document.getElementById() to select elements in JavaScript and convert any old code you come across immediately.

While this simple topic has been discussed a ton already, some of the material out there on the net is old and in some cases hold old rebuttal comments that don’t apply anymore.

I imagine most people will find this article by searching for document.all in Firefox. It is no longer a supported selector and does not work at all in Firefox.

The document.all selector

document.all was used back in the old days to select elements in Internet Explorer.

It did have unique features, such as being an object with helpful properties or being able to return elements by both name or id. However, you should not use name as a selector. To learn more about why you should use id as a selector, read this article.

Never use document.all

Use document.getElementById() in all instances instead of document.all. It has been fully supported for well over a decade now.

This is probably the very first method you are taught when learning JavaScript besides alert() for the obligatory ‘Hello World’.

While this is very basic, it is important to instill good scripting habits early on… or get rid of bad habits if you are a veteran.

By my estimates, only about 0.001% of users still have IE4, so there is absolutely positively no reason to ever use this obsolete selector.