Is it possible to change the value of src attribute of <input type='image' alt="Text will be shown if pics are disabled" src='somepic.png'../>
by css?
The problem is:
I want to specify which pic will be shown as submit button just using css (so the design team will change only css files!).
If I use the alternative way like <input type="submit" class="cssclass" value=" " alt="Text will be shown if pics are disabled"/>
and specify the background of this element in css - it doesn't work well if pics are disabled. - No any alternative text is shown instead of pic. However the first way solves this situation...
Please advice something
Thanks.
No, CSS cannot change the value attribute of an input , or indeed any attribute of any element.
No you can't set the image src attribute via CSS.
No. CSS is a presentation language. It cannot be used to alter the semantics and structure of a document.
The <input type="image"> defines an image as a submit button. The path to the image is specified in the src attribute.
Here it is: http://jsfiddle.net/kizu/66JXn/
Some notes about this solution:
Use <button></button>
, 'cause it can include other blocks.
You'll need a bit of extra code to make all these work in Fx and IE:
You place the text and another element inside, that would overlay the text. So when the images would absent, the text would be accessible.
That's it :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With