Using Label
Almost all form controls can have a "shortcut" with a label:
#r {display:none}
#l {
display:block;
width:32px;
height:32px;
background:url(https://i.stack.imgur.com/OV6nj.jpg?s=32)
}
<form>
<textarea cols="40" rows="5"></textarea>
<input id="r" type="reset">
<label id="l" for="r"></label>
</form>
This works to stylize checkbox, radiobutton, and many other controls. The label
is a great ally of CSS.
Remember that styling is an example, if you want to keep the flow equal to the original button, you can use inline-block
instead of block
.
Also, if you don’t want to put the image in CSS, you can simply put the img
within the label
. Usually it is more interesting to leave in CSS, for being styling, and not content.
Stylizing the input
Depending on the level of compatibility you want, simply style with CSS:
#r {
display:block;
border:none;
width:32px;
height:32px;
background:url(https://i.stack.imgur.com/OV6nj.jpg?s=32)
}
<form>
<textarea cols="40" rows="5"></textarea>
<input id="r" type="reset" value="">
</form>
You can hide the input and style a label that has the attribute
for
pointed to the input.– Renan Gomes
The problem is making it buddy.
– Lone Tonberry