Skip to content

Commit

Permalink
glossary: update attribute (#33386)
Browse files Browse the repository at this point in the history
* update: xml attribute

* Apply suggestions from code review

Co-authored-by: Chris Mills <[email protected]>

* add equivalence

---------

Co-authored-by: Chris Mills <[email protected]>
  • Loading branch information
PassionPenguin and chrisdavidmills committed May 7, 2024
1 parent f3fbc8c commit 81217ba
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions files/en-us/glossary/attribute/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ An **attribute** extends an HTML or XML {{Glossary("element")}}, changing its be

An attribute always has the form `name="value"` (the attribute's identifier followed by its associated value).

You may see attributes without the equals sign or a value. That is a shorthand for providing the empty string in HTML, or the attribute's name in XML.
You may see attributes without an equals sign or a value. That is a shorthand for providing the empty string in HTML; such attributes are considered to be [boolean attributes](/en-US/docs/Web/HTML/Attributes#boolean_attributes). However, this is not allowed in XML: XML requires the equals sign followed by the attribute name.

```html
The following code provides examples of different boolean attribute forms in HTML:

```html example-good
<input required />
<!-- is the same as… -->
<!-- is equivalent to -->
<input required="" />
<!-- or -->
<input required="required" />
<input required="anything" />
```

In XML, attributes without equals sign or value will throw a syntax error:

```xml-nolint example-bad
<tag id />
```

## Reflection of an attribute
Expand Down Expand Up @@ -51,3 +59,4 @@ console.log(attr.value); // Prints `Modified placeholder`

- [HTML attribute reference](/en-US/docs/Web/HTML/Attributes)
- Information about HTML's [global attributes](/en-US/docs/Web/HTML/Global_attributes)
- XML StartTag Attribute Recommendation in [W3C XML Recommendation](https://www.w3.org/TR/xml#sec-starttags)

0 comments on commit 81217ba

Please sign in to comment.