Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to button with image HTML

Tags:

html

css

I have a button which is initially an image and performs an action when clicked. However I want to add the title Submit to the button.

How could I do this?

<form name="input" action="" method="post">
<input type="text" name="emailaddress" placeholder="email address" class=emailInput />
<button type="submit" style="border: 0; background: transparent">
    <img src="submit.png" width="50" height="31" class=submitButton alt="Submit" />
</button>
</form>
like image 885
max_ Avatar asked Dec 08 '25 03:12

max_


1 Answers

Best way is to do this with CSS since the image is actually a background for the text I suppose.

  • remove the image from inside the button
  • use css to decorate the button
  • place the text in the button

css:

button {
    background:transparent url(submit.png) no-repeat left top;
    width:50px;
    height:31px;
}

more here.

like image 52
Caspar Kleijne Avatar answered Dec 10 '25 17:12

Caspar Kleijne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!