tags:

views:

124

answers:

6

Hi,

is there a way to add an image to a regular <input type = "button" /> besides the text?

A: 

An image in the button or an image as the button?

Image AS button:

<input type="image" src="/images/myImage.png" alt="An image as a button"/>

Image inside button....I don't think so.

McAden
+1  A: 

You want the "image" input type

<input type="image" src="/path/to/image.png" value="Click here" size="32,32" border="0" />
Dolbz
+3  A: 

Yes - you should be able to set the background image on the button in CSS. My preferred method is to use the button tag e.g.

<button type="submit">text</button>

You can put any html you want within the tag and style it.

matpol
<button type="submit"><img src="..." alt="" /><-Image</button>
Moak
Moak - true - but I would use CSS to add a background image somehow
matpol
+1  A: 

We can have css for button .

 

background: url(images/blue.png)  ; 

pavun_cool
+1  A: 

Button in HTML (For location I'd normally place all images in a images folder)

<BUTTON type="submit" src="/images/Button.png" value=""> 

Button via CSS, where myBtn is defined in the class file

<BUTTON type="submit" class="myBtn" value=""> 

Where myBtn is defined in the class file

.myBtn{ 
background: url(/images/Button.PNG) no-repeat; 
cursor: pointer; 
width: 140px; 
height: 80px; 
border: none; 
} 
kevchadders
+1  A: 
<input type="button" style="background-image:url(flower.jpg)" value="Click">

It will set the background image for button using HTML.

rekha_sri