Solved

howto put image in button

Posted on 2011-09-07
5
211 Views
Last Modified: 2012-05-12
I'm trying to put an image in a button, but I can't seem to do it without the extra space on either side of the image (see attached image). How do I do this? Here's what I have:

<button type=button onclick="window.open('tmp/ACHtrans.jsp','_BLANK')">
      <img style="margin: 0; border: 0" src=images/download.jpg>
    </button>

button.JPG
0
Comment
Question by:jmarkfoley
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36500458
No need to use button
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<style>
		a.button
		{
			border:2px solid #ccc;
		}
		a.button img
		{
			width:100px;
			height:25px;
		}
	</style>
</HEAD>

<BODY>
	<a href="javascript:window.open('tmp/ACHtrans.jsp','_BLANK')" class="button"><img src="lastscan.jpg"/></a>
</BODY>
</HTML>

Open in new window

0
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 500 total points
ID: 36500475
<INPUT TYPE="image" SRC="images/download.jpg" HEIGHT="30" WIDTH="173" BORDER="0" ALT="Submit Form">
0
 
LVL 1

Author Closing Comment

by:jmarkfoley
ID: 36500510
That's a winner! Thanks
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36500515
And why not mine??
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 36507361
gurvinder372: Yours would have worked too (with additionally removing the blue border), but santoshmotwani's was far simpler without dealing with styles for the href tag, so I picked that one.

My implementation:

<input type=image src=images/download.jpg onclick="location='tmp/ACHtrans.jsp'">
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now