Reputation: 13063
I have a grid that displays some database records, and to the left of these I want to have edit/delete buttons.
I want these buttons to have a simple icon. I would use the following html:
<button class="grid-edit" type="button" />
<button class="grid-delete" type="button" />
and then a background-image
etc to make them visible and style them.
However I'm concerned that the HTML itself is not meaningful enough, with regards to the "semantic web" concept.
I see several options:
<img>
element - but img
should not be used for stylistic purposes;<input type="image">
instead. Is this the correct way?Upvotes: 1
Views: 3156
Reputation: 3474
Markup-wise, you have a button element with a descriptive class attribute. That's pretty semantic.
Accessibility-wise, a screen reader will have nothing to indicate the button's purpose since there is no text. You can either provide the text within the button, and use CSS to visually hide it (not using display: none
or visibility: hidden
, since those hide it from screen readers too), or provide an alternate text source for screen readers.
<button>text</button>
<button><span>text</span></button>
element-invisible
class<button aria-label="text" />
Upvotes: 3