471,874 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,874 software developers and data experts.

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 2546
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Mikko Rantalainen | last post: by
3 posts views Thread by =?Utf-8?B?V2lsbA==?= | last post: by
reply views Thread by YellowAndGreen | last post: by

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.