views:

663

answers:

4

I noticed in our code that there is a disabled = true' i the source code for anchor tag. I was wondering why it works in IE. I also searched the internet and it is also being used in a lot of source code via a search in the net. I have been searching if ture, a wrong spelling of true can also be used by IE.

Does anybody have any idea about this?

+7  A: 

It used to be that to disable an element, you just did <input type="text" disabled>, so most browsers don't really care what goes in that attribute. I believe making it disabled="disabled" became a standard solely so that the code would be valid XML.

notJim
Addition: HTML5 now codifies the <input disabled> syntax and even gives it in examples: http://www.whatwg.org/specs/web-apps/current-work/
Nickolay
HTML 4 had that: http://www.w3.org/TR/html4/interact/forms.html#adef-disabled (HTML 3.2 didn't have a disabled attribute at all, but the checked attribute works that way: http://www.w3.org/TR/REC-html32#input )
David Dorward
This is called attribute minimisation, and goes back to the SGML standard on which HTML was (sort of) originally built.
bobince
+3  A: 

IE only checks for the existence of the disabled property. It's value doesn't matter.

Zed
A: 

IE is notorious for allowing error-filled HTML code to work; this is why many people mistakenly "blame" it for issues, but actually it's just they've been doing things wrong.

I believe IE allows diabled to be set to anything (other than false) to mean that it's true, because I think in the past people have written disabled='disabled', and other such things.

Noon Silk
A: 

The disable attribute can take one value: 'disabled'

All instances of this attribute in HTML allow the quotes, separator and name to be omitted (leaving just the unquoted value).

Since browsers implement tag soup parsers and perform vast amounts of error recovery, disabled=pretty much anything will be treated as disabled.

(And I guess that Microsoft have implemented disabled on anchors for some reason, despite the attribute not existing for that element).

David Dorward