HTML - Why boolean attributes do not have boolean value?

前端 未结 7 867
小蘑菇
小蘑菇 2020-12-03 10:41

I noticed that some elements have attributes which are boolean. I wonder why the values are not true or false? or 1 and 0? Are there any reason behind why they are like this

7条回答
  •  天命终不由人
    2020-12-03 11:12

    For the disabled attribute I think it's the presence of the attribute that disables the element regardless of its value.

    It guess one of the reasons could be to allow more values than just yes/no in the future. For instance, instead of visible=true/false, you can have visibility=visible/hidden/collapsed

提交回复
热议问题