Skip to content

Commit

Permalink
An attribute must have a value (#36450)
Browse files Browse the repository at this point in the history
* Attribute can't have no value

HTML attributes by definition are name-value pairs and can't have no value. See [this article](https://8hob.io/posts/set-attribute-without-value-in-js/#an-attribute-always-has-a-value) for a quick explanation.

Relevant HTML standard: https://html.spec.whatwg.org/multipage/syntax.html#attributes-2

* Use m-dash instead of hyphen

* Clarify implicit attribute value

* consistent commas

* Update files/en-us/glossary/boolean/html/index.md

* Grammar changes

* Update files/en-us/glossary/boolean/html/index.md

* Consistent semicolons

---------

Co-authored-by: sideshowbarker <[email protected]>
  • Loading branch information
xuhdev and sideshowbarker authored Oct 22, 2024
1 parent 65f28e9 commit 29aa893
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions files/en-us/glossary/boolean/html/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ page-type: glossary-definition

{{GlossarySidebar}}

A **boolean attribute** in {{Glossary("HTML")}} is an {{glossary("attribute")}} that represents `true` or `false` values. If an HTML tag contains a boolean attribute - no matter the value of that attribute - the attribute is set to `true` on that element. If an HTML tag does not contain the attribute, the attribute is set to `false`.
A **boolean attribute** in {{Glossary("HTML")}} is an {{glossary("attribute")}} that represents `true` or `false` values. If an HTML tag contains a boolean attribute no matter the value of that attribute the attribute is set to `true` on that element. If an HTML tag does not contain the attribute, the attribute is set to `false`.

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

- no value at all, e.g. `attribute`
- the empty string, e.g. `attribute=""`
- attribute's name itself, with no leading or trailing whitespace, e.g. `attribute="attribute"`
- 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; e.g., `attribute="attribute"`

> [!NOTE]
> The strings "true" and "false" are invalid values. To set the attribute to `false`, the attribute should be omitted altogether. Though modern browsers treat _any_ string value as `true`, you should not rely on that behavior.
Expand Down

0 comments on commit 29aa893

Please sign in to comment.