What is the syntax for boolean attributes, e.g. a checked checkbox, in HTML?

前端 未结 9 1454
故里飘歌
故里飘歌 2020-12-05 18:09

Sounds like a bit of a silly question, but I am wondering what is the best way of stating that a checkbox is checked/unchecked in HTML.

I have seen many different ex

9条回答
  •  盖世英雄少女心
    2020-12-05 18:40

    The W3C spec seems to imply that just the checked attr being there is correct. Does that mean that checked="false" and checked="no" will still check the box though?

    Exactly. That's why it's a bad idea to use checked="true" and checked="yes", they imply that checked="false" and checked="no" will not check the box.

提交回复
热议问题