473,563 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a way to set the image for an <input type="image"> in CSS?

Hello,

If I have the following HTML...

<input type="image" src="fred.gif">

.... is there a way to specify the image in CSS rather than in the HTML?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Jan 19 '06 #1
2 2743
Alan Silver wrote:
If I have the following HTML...

<input type="image" src="fred.gif">
Then you should fix it to use <input type="submit" value="...">.
... is there a way to specify the image in CSS rather than in the HTML?


Yes and no. You could e.g. use a dummy image (transparent single-pixel
image) as fred.gif and use CSS to set a background image for the
element. But don't. To begin with, it would fail whenever CSS is turned
off or your author style sheet is ignored, as well as when browsing in
no-images mode.

The relevant thing is that you should not use image submit buttons in
the first place. For reasons, see
http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html
Jan 19 '06 #2
>> If I have the following HTML...
<input type="image" src="fred.gif">


Then you should fix it to use <input type="submit" value="...">.


It was air code, purely intended to show the tag I meant. I only use
full, valid HTML in real documents ;-)
... is there a way to specify the image in CSS rather than in the HTML?


Yes and no. You could e.g. use a dummy image (transparent single-pixel
image) as fred.gif and use CSS to set a background image for the
element. But don't. To begin with, it would fail whenever CSS is turned
off or your author style sheet is ignored, as well as when browsing in
no-images mode.

The relevant thing is that you should not use image submit buttons in
the first place. For reasons, see
http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html


OK, I'm convinced!!

Don't you wish it was always that easy?

Thanks for the reply.

--
Alan Silver
(anything added below this line is nothing to do with me)
Jan 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
13059
by: Gregory | last post by:
Hello, I'm trying to do the above in order to process an image and return the result to an html image control. It fails and my key suspects are either the variable that I'm passing in - ImageName - for processing, or the return data which is done (or not as the case may be) by imagejpeg($img) in the script, after header("Content-type:...
5
10430
by: Mikko Rantalainen | last post by:
See example at <URL:http://www.cc.jyu.fi/~mira/moz/formtest.php>. The problem is that the label of submit button is always centered on the button regardsless of 'text-align' property in CSS. Considering that I can style everything else, this must be a bug, right? Any suggestions how to fix the issue with Mozilla 1.4? How about other...
1
3285
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic as this is the reason (security) that I want to restrict their selection. Any help on this one will be greatly appreciated. The page is using...
17
3175
by: Alan Silver | last post by:
Hello, I have a page which I am converting to use themes. The page has an HTML <input type="image"> element that is used to post to another page. I would like to replace this with a server control so I can add a skinid. I tried adding runat="server" and the skinid to the existing control, but that didn't work. Any other ideas? TIA --
12
9613
by: menmysql | last post by:
hi i want to dispaly an image on my webpage which is selected using <input type="file">. is it possible. please reply urgent regards
3
2250
by: =?Utf-8?B?V2lsbA==?= | last post by:
I have an image "button" which causes a postback. I handle the "click" with If Request.Form("btnBU7WD6_Submit.X") 0 Then... this works great. However, when a user double-clicks the image button the Page_Load (postback) is processed twice. This is a problem. Is there any easy way to detect that the image button has been double-cliked
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3628
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.