Search code examples
htmlimagereferencequotation-marks

How to reference an Image within quotation marks in HTML


I was wondering how to display an image inside of a button.

I have this code:

<input type="button" value="TEXT GOES HERE" onclick="showImage();"/>

And I wish to place an image within the button instead of text. I tried setting the value field to the path of the image:

<input type="button" value="this.src='Images/pickups.png'" onclick="showImage();"/>

but instead of displaying the image it simply displays the this.src... as text.


Solution

  • If you want a button, use button html tag, and inside put imgtag with src attribute pointing to your image url

    <button type="button"  onclick="showImage();"><img src="favicon.ico"/></button>