0

Is HTML:

<button type="submit" disabled>Some text</button>

equivalent to

<button type="submit" disabled="true">Some text</button>

And, would something like this work as well?

<button type="submit" disabled="You know it">Some text</button>

If it wouldn't work on a specific browser, can you say which one?

Coding Duchess
  • 6,445
  • 20
  • 113
  • 209
Jon
  • 2,566
  • 6
  • 32
  • 52

1 Answers1

4

The only value disabled is allowed to have is disabled. You can omit everything except the value (disabled) in HTML 4 and earlier. You can omit everything except the name (also disabled) in HTML 5.

From the spec:

A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

This is fine:

disabled

This is fine:

disabled="disabled"

This is fine:

disabled=disabled

This is not HTML:

disabled="true" 

This is not HTML:

disabled="You know it"

You can expect most browsers to perform error recovery on invalid values, but that is no reason not to simply write real HTML in the first place.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335