Which way is better for making image buttons?
Using <a>:
set background image to my image
have to specify <a href="#">, however, there will be a url in browser status bar, which is a bit annoying.
Using <div>:
set background image to my image
no url shows in browser status bar, however, have to add cursor:pointer in .css
I wouldn’t go for a div personally, because semantically a div is not a button. If you want a button that performs a JavaScript action, I’d probably just use the
<button></button>tag. You can place other HTML elements inside a button tag as you would a div, and it’s better semantically.To reiterate what @Richard JP Le Guen said, ideally you’d add these buttons using JavaScript too, so that people without JavaScript enabled will not see them, or you can offer an alternative functionality for those without JS enabled.