Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an image as a submit button

Tags:

html

css

If I want to make my own clickable buttons, I can do this:

<a href="javascript:;" class="button">Sign up</a>

Where CSS rules for a.button causes the link to be shown as a button. If I apply the same trick to <input type="submit" />, I get the button image but it is shown on top of the default submit button and the cursor doesn't change to a hand like it does on <a> tags.

How can I fix this behavior?

like image 874
Pieter Avatar asked Mar 12 '11 15:03

Pieter


People also ask

Can you use an image as a submit button?

Definition and UsageThe <input type="image"> defines an image as a submit button. The path to the image is specified in the src attribute.

Can I put an image in a button HTML?

Use the <img> Tag Inside the <button> Tag to Embed Image in the HTML Button. This <img> tag is used to embed an image on an HTML page. The images are not literally placed into the webpage; images are linked to the webpages by given pathways.

How do you make an image clickable in HTML?

To use image as a link in HTML, use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Under the image tag src attribute, add the URL of the image. With that, also add the height and width.


2 Answers

You can use appropriate CSS properties such as

border: none;
background: transparent;
cursor: pointer;

to remove the default styles from your input type="submit" button.

like image 103
Jon Avatar answered Sep 22 '22 11:09

Jon


You could use an input type="image" instead.

It is used like this:

<input type="image" src="{your image}" alt="{alternate text}" />
  • input type="image" on MSDN
  • input on MDN
like image 20
kapa Avatar answered Sep 21 '22 11:09

kapa