Is it possible, via CSS to remove or change the src reference in the markup below?
The easy thing to do would be to change the markup, however, this code is in the wild and I need to deal with it as it is, so I'm trying to remove the image and use a background image instead.
<input type="image" src="wp-content/uploads/image.png" name="submit" class="submit" value="Submit" />
No you can't set the image src attribute via CSS. The closest you can get is, as you say, background or background-image .
Definition and Usage The src attribute specifies the location (URL) of the external resource.
Change Img src If you'd like to replace an image on your website, then you can simply change the image file path or URL in its source attribute. You can change this attribute at any time. It's important to note that the new image inherits the height and width attributes of the original image.
You can experiment with setting height and width to 0, add a padding and set the background image. You will have to make it display: block
or display: inline-block
for the height to take effect.
Here's an example - http://jsfiddle.net/zBgHd/1/
Actually, I just figured it out.
.submit {width:0;height:28px;background:url(go.png) no-repeat; padding-left:28px;}
My replacement image is 28x28. By specifying a left padding equal to that, and a width of zero, it effectively pushes the image off the viewable area of the box, leaving the background image to show.
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