Boolean attribute chỉ có hai trạng thái: có mặt = true, vắng mặt = false.
Giá trị gán cho nó không được xét đến.
html
<input disabled> <!-- true -->
<input disabled=""> <!-- true -->
<input disabled="disabled"> <!-- true -->
<input disabled="false"> <!-- VẪN true — chỉ cần attribute có mặt -->
<input> <!-- false -->Nhóm hay gặp: disabled, checked, selected, required, readonly, autofocus, hidden, multiple, defer, async.
Muốn tắt thì phải gỡ hẳn attribute, không phải gán giá trị khác:
js
input.removeAttribute('disabled') // đúng
input.disabled = false // đúng — property nhận boolean thật
input.setAttribute('disabled', 'false') // sai — vẫn disabledChốt: phân biệt attribute (chuỗi trong HTML) và property (giá trị boolean trong DOM) là mấu chốt của câu này — trong React, disabled={false} an toàn vì React tự gỡ attribute.