3 ms·
No, your first code snippet is totally fine. The button's name comes from its descendent elements by default. In this case, the `alt` attribute of the image pro
by extra88 3y ago
No, your first code snippet is totally fine. The button's name comes from its descendent elements by default. In this case, the `alt` attribute of the image provides the name.
Sara is good source for accessibility information but I think you've misinterpreted that post. If an icon button uses an `img`, making the image's `alt` the name of the button works well. If the button's icon comes from an inline SVG, background image, or icon font, I recommend Sara's first technique, visually hidden text within the `button`; names from text nodes are more robust than from attributes (`alt` being an exception, in part because it has been around far longer).
- d1sxeyes 3y agoThank you for the correction! Always good to learn.