Question:
I want to create a hyperlink with both text and a leading or trailing icon. This can be accomplished in at least two ways:
- With CSS setting a background-image property
- By creating a ASP.NET Html helper that generates an anchor tag followed by an image tag.
Are there more?
I’m guessing this is a problem that has been solved a million times, and there might be a best practice. I see negative and positive sides of both approaches, and I’d like some input from you guys.
Metaquestion:
Both here and on programmes.stackexchange I get the warning “your question appears subjective and is likely to be closed”. Where do one ask subjective questions nowadays?
Is the icon content? i.e. does it add (not duplicate) meaning to the document?
If so, it is content and should be an
<img>element with a suitable alt attribute.If it decorative? Then CSS is probably more appropriate.