When designing a web UI, I am considering using iconography to represent actions such as adding, editing, deleting, and searching for items. However, I want to ensure that the purpose of each action is clear without displaying text and cluttering the UI space. One way to achieve this is:
Add an
img
element inside thea
nchor tag. Theimg alt
attribute describes the icon (alt="pencil icon"), while the title attribute explains the action (i.e. "Click here to edit this widget").Use css to display the image as a background within the
a
nchor tag. The anchor's content should describe the action, wrapped in a span element with a display style set to none. Additionally, include a title attribute matching the content.
Option #2 may be easier to implement in an asp.net mvc app, as it separates design concerns from markup concerns. Defining the image in CSS simplifies code maintenance, allowing changes to the img src location by only adjusting the CSS file. Lastly, removing the CSS would revert to full text accessibility.
However, nesting the link content into a span for display: none;
in the CSS feels somewhat cumbersome. Additionally, hover effects using the :hover selector might result in slower image swapping compared to JavaScript methods. Is there anything I may have overlooked?