Movatterモバイル変換


[0]ホーム

URL:


  1. Glossary
  2. Boolean
  3. Boolean attribute (HTML)

Boolean attribute (HTML)

Aboolean attribute inHTML is anattribute that representstrue orfalse values. If an HTML tag contains a boolean attribute — no matter the value of that attribute — the attribute is set totrue on that element. If an HTML tag does not contain the attribute, the attribute is set tofalse.

If the attribute is present, it can have one of the following forms:

  • the attribute name alone; e.g.,attribute, meaning its implicit value is the empty string
  • the attribute with a value of the empty string; e.g.,attribute=""
  • the attribute with a value of the attribute's name itself, with no leading or trailing whitespace and case ignored; e.g.,attribute="attribute",attribute="ATTRIBUTE"

Note:The strings "true" and "false" are invalid values. To set the attribute tofalse, the attribute should be omitted altogether. Though modern browsers treatany string value astrue, you should not rely on that behavior.

Here's an example of a HTML boolean attributechecked:

html
<!-- The following checkboxes will be checked on initial rendering --><input type="checkbox" checked /><input type="checkbox" checked="" /><input type="checkbox" checked="checked" /><input type="checkbox" checked="Checked" /><!-- The following checkbox will not be checked on initial rendering --><input type="checkbox" />

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp