Skip to content

Instantly share code, notes, and snippets.

@ArjanSchouten
Last active May 7, 2021 12:14
Show Gist options
  • Save ArjanSchouten/0b8574a6ad7f5065a5e7 to your computer and use it in GitHub Desktop.
Save ArjanSchouten/0b8574a6ad7f5065a5e7 to your computer and use it in GitHub Desktop.
Below is a list of html boolean attributes. All these attributes must be leaved empty, filed with 0|1, filled with on|off, filled with true|false or used as a flag.
async
autocomplete
autofocus
autoplay
border
challenge
checked
compact
contenteditable
controls
default
defer
disabled
formNoValidate
frameborder
hidden
indeterminate
ismap
loop
multiple
muted
nohref
noresize
noshade
novalidate
nowrap
open
readonly
required
reversed
scoped
scrolling
seamless
selected
sortable
spellcheck
translate
@pkonieczniak
Copy link

Thanks, for snippet :)
Instead for formNoValidate written in camelCaseNotation should be formnovalidate.

@f0rmat1k
Copy link

f0rmat1k commented Jul 5, 2018

Not sure, that all these attributes are boolean (according specs). E.g. translate isn't. Values yes and no don't mean, that translate is boolean.

@phptechs
Copy link

autocomplete is not boolean. It's enumerated, just takes on|off.

@bkdotcom
Copy link

bkdotcom commented Sep 27, 2018

not an attribute:

  • indeterminate (this is a property of a type="checkbox" input, but is not an attribute

not boolean

  • autocomplete : enum (on|off)
  • border
  • challenge : <keygen name="name" challenge="challenge string" keytype="type" keyparams="pqg-params"> (also, keygen is deprecated)
  • spellcheck : enum (true|false)
  • translate : enum (yes|no)

missing from list:

  • itemscope
  • nomodule
  • typemustmatch

obsolete / deprecated / never-was

  • compact - dir and ol
  • nohref - area
  • noresize - frame
  • noshade - hr
  • nowrap - dd, dt, td, th
  • scrolling - iframe
  • seamless : iframe - removed from draft
  • sortable : table - removed from draft

@JeremySorensen
Copy link

here is the list created from the original list and applying the suggested changes from @bkdotcom
(I did not verify anything, just mechanically applied the changes):

async
autofocus
autoplay
checked
contenteditable
controls
default
defer
disabled
formNoValidate
frameborder
hidden
ismap
itemscope
loop
multiple
muted
nomodule
novalidate
open
readonly
required
reversed
scoped
selected
typemustmatch

@j9t
Copy link

j9t commented Apr 28, 2020

From checking the living HTML spec, HTML currently has 25 Boolean attributes.

From the list above, contenteditable is not one of them (enumerated); frameborder, scoped, and typemustmatch are not part of the HTML standard.

@bkdotcom
Copy link

bkdotcom commented Apr 29, 2020

@j9t

From checking the living HTML spec

where did you find a list?
or did you have to scan the documentation for each tag?
https://html.spec.whatwg.org/multipage/semantics.html#semantics

edit:
answering my own question:
https://html.spec.whatwg.org/#attributes-3

@j9t
Copy link

j9t commented Apr 29, 2020

@bkdotcom, I’ve been preparing an overview for Boolean attributes, too, and had for that gone through https://html.spec.whatwg.org/, at some point looking for is a boolean. That search seems to lead to all attributes.

PS.
Aforementioned overview is now available at The 25 Boolean Attributes of HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment