Short answer
Use an <img> - not a button, nor a binding, nor an input, as the others assume that this element is interactive, even without JavaScript.
Long answer
clicking on the image should trigger an action (via javascript, but that's not the point).
I disagree; this is the point :)
Since clicking activates JS-only features, your image should only be available in the JS environment.
So the correct way is to paste it using JavaScript; while the HTML document must be semantically correct, the DOM structure does not have to be semantically correct, so which element you use becomes irrelevant.
Wrong way
<div> Click on the image to do something: <a href="javascript:wtv()" style="background-image:url(...)"> </a> </div> <div> Click on the image to do something: <input type="image" onclick="wtv()" src="..." /> </div> <div> Click on the image to do something: <img onclick="wtv()" src="..." /> </div> <div> Click on the image to do something: <button onclick="wtv()"><img onclick="wtv()" src="..." /></button> </div>
This is all wrong because a user who does not have JavaScript sees these elements and cannot use them.
Of all these, I would say that <img> is a lesser evil, since it does not offer an interactive element. <a> uses the most evil, since the anchor must be a hyperlink to another document, and you should never use the javascript: protocol.
You will still have the same problem if you add JavaScript event handlers from outside:
document.getElementById("myButton").onclick = wtv; <div id="myButtonParent"> Click on the image to do something: <a id="myButton" href="#" style="background-image:url(...)"> </a> </div>
Like, again, you still have a (non-working) hyperlink available to those users who don't have JavaScript.
Instead
Instead, insert the whole damn thing using DOM scripting! I am going to use <img> with the onclick event:
window.onload = function() { var img = document.createElement("img"); img.src = "..."; img.onclick = wtv; img.style.cursor = "pointer";