Requiring The Alt Attribute In HTML5 - Juicy Studio
Có thể bạn quan tâm
I asked on Twitter and on Juicy Studio for opinions about whether or not the alt attribute should be required in HTML 5 on the img element for conformance and the reasons why. The following is a summary of the responses for and against requiring the alt attribute.
Reasons why the alt Attribute Should Be Required
- If the image is decorative, it should be provided with CSS. If the image has content, then the alt attribute should be used or the content will not be perceivable to some users.
- The alt attribute should be mandatory in HTML5 with a note pointing to WCAG 2.0 for guidance, as WAI are the experts in this area.
- Not requiring the alt attribute allows broad, dangerous ideas of what should and should not have alt. Laziness will dictate.
- Authors should be required to make a decision about alt text for every image.
- Without alt text, assistive technologies rely on heuristics to determine the purpose of the image, which often results in gibberish — for example, announcing machine generated file names as the link phrase for links.
- Bad alt text is much better than no alt text.
- Requiring alt text encourages people in the right direction.
- Because people do not always get the alt text correct, it is not a reason not to require it.
- Requiring alt text creates a teachable moment.
- The alt attribute should be required, or an additional attribute provided to indicate when alt text has not been provided.
Reasons why the alt Attribute Should Not Be Required
- Making the alt attribute required results in people providing nonsense values.
- Making the alt attribute required does not mean it will be used correctly.
- If alt text is not provided and the authoring tool has no context, it is unable to generate meaningful alt text. In those circumstances, the authoring tool should omit the alt attribute completely, and let the user agent repair the content. It is unreasonable to guide authoring tools to let a user action violate the syntax of the underlying data format, so omitting the alt attribute should be considered valid HTML5.
- It is not reasonable to expect anyone to provide alt text when uploading several thousand photos all at once.
- Provide the alt text with aria-labelledby is better than requiring the alt attribute.
- Providing alt text should be considered best practice, not required.
- Requiring alt text is merely philosophical without context.
- The alt attribute should not be required, but flagged at validation as a warning.
Repair Techniques
When alt text has not been provided by the author and it is not possible to generate meaningful meta data about the image, the authoring tool should not generate default alt text, as that is likely to result in poor quality alt text; the number one reason given by those who responded that alt text should not be required. When alt text has not been provided, and it is not possible for the authoring tool to generate any kind of repair, such as meta data, the alt attribute should be omitted. The resulting output, however, should be considered invalid, as it is not structurally complete.
It is unreasonable to state that the output from authoring tools should always be considered valid, regardless of input from the user. Considering output to be correct regardless of input is at odds with the general garbage in garbage out (GIGO) principle. For example, an author can provide an address with the address element that isn't a contact address, which would not be considered compliant. The author obviously has a responsibility in using an authoring tool.
HTML5 the Markup Language
A markup language should be concerned about structure. The img element is not complete without an alternative, as it will not be perceivable by some people. The simplest and easiest way to ensure the img element is structurally complete is to provide an alt attribute in accordance with guidance provided by WCAG 2.0. If the alt attribute is not provided, there should be a way of ensuring an accessible alternative is provided.
Alternatives to the alt Attribute
One of the suggestions against the alt attribute being required is that WAI-ARIA's aria-labelledby could be provided instead. WAI-ARIA's aria-labelledby attribute could provide an accessible alternative, but only when the natural concise text alternative is available elsewhere on the page, such as in the image's description. Most of the time, this is unlikely to be the case — for example, when images are used as navigation items. However, there are examples where aria-labelledby could be considered an accessible alternative for an image.
Another alternative that could be conveyed from an accessibility architecture to assistive technology is the legend element used with the figure element in HTML5.
Requiring an Accessible Alternative
A text alternative for non-text objects ensures the content is structurally complete and accessible. For the img element, the accessible alternative can be provided by any of the following.
- alt attribute
- aria-labelledby attribute
- legend element
It is preferable that the accessible alternative always be provided by the alt attribute, as the value can be suppressed (with alt="") when it clashes with other sources for an alternative, such as the legend element. If it is decided that the alt attribute should not be required for conformance, then it is recommended that it be mandatory to provide an accessible alternative through one of the preceding three methods and that any one the three methods be required for conformance.
As the img element is structurally incomplete without a text alternative, HTML5 should make it mandatory for an accessible alternative to be provided; either by making the alt attribute required, or by providing the aria-labelledby attribute or the legend element with the figure element when the alt attribute has not been provided.
Từ khóa » Html5 Alt Tag
-
HTML Img Alt Attribute - W3Schools
-
HTML Alt Attribute - W3Schools
-
Image ALT Tag Tips For HTML - Accessibility At Penn State
-
: The Image Embed Element - HTML - MDN Web Docs - Mozilla
-
Alt Attribute - Wikipedia
-
HTML Img Alt Tags For SEO Best Practice - Search Engines Love ...
-
Learn How Does Alt Tag Work In HTML With Examples - EduCBA
-
HTML | Alt Attribute - GeeksforGeeks
-
Can We Use An Alt Attribute With The Video Tag? - Codecademy Forums
-
Decorative Images | Web Accessibility Initiative (WAI) - W3C
-
Resources On Alternative Text For Images - W3C
-
What Is An ALT Tag? AT Internet Definition
-
Why An HTML Image Alt Text Doesn't Show On Hover - Computer Hope