content icon indicating copy to clipboard operation
content copied to clipboard

Required="required" VS required

Open KimGreenbush opened this issue 3 years ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required

What specific section or headline is this issue about?

Required attribute example

What information was incorrect, unhelpful, or incomplete?

Just required is needed to mark an input as required but there's no example covering this.

What did you expect to see?

An example of using the required attribute that is just the word required.

Do you have any supporting links, references, or citations?

https://www.w3schools.com/TAGS/att_required.asp

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/html/attributes/required
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/html/attributes/required/index.md
  • Last commit: https://github.com/mdn/content/commit/61a8cddbde9257e05c55063985f28ac8d364082a
  • Document last modified: 2022-07-01T05:22:39.000Z

KimGreenbush avatar Sep 12 '22 16:09 KimGreenbush

Additional references

  • https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#boolean_attributes
  • https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes

The example is valid, but perhaps a bit verbose. I suggest this variant, which maintains HTML & XML validity and is less verbose

    <input type="text" required="" />

There might be a documented convention for writing boolean attributes in MDN examples, but I don't know where to look.


Edit: MDN's documented convention for writing boolean attributes is found in https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/HTML#boolean_attributes

Andrew-Cottrell avatar Sep 16 '22 09:09 Andrew-Cottrell

Thanks for raising this — I’ve opened #21036 with a fix.

After that fix is merged, this issue will automatically be marked as resolved, and closed.

sideshowbarker avatar Sep 24 '22 09:09 sideshowbarker

Unfortunately I can’t contribute a patch for this after all, because apparently we have a our Prettier configuration set up to require self-closing tags in HTML snippets, and I can’t justify touching markup snippets like this without also fixing markup antipatterns and bad practices like that one.

sideshowbarker avatar Sep 25 '22 01:09 sideshowbarker