Solved

howto put image in button

Posted on 2011-09-07
5
213 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

856 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