How to Embed Image in a Button Element in HTML
Topic: HTML / CSSPrev|Next
Answer: Use CSS and <img>
Element
You can simply place or embed the <img>
element inside the <button>
element and apply some CSS styling to give it a look like image button. However, if you're trying to create an image submit button you can alternatively use the <input type="image">
button.
Let's try out the following example to understand how it basically works:
Example
Try this code »<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Display Image inside button Element in HTML</title>
<style>
.image-btn{
background: none;
border: none;
padding: 0;
}
.image-btn img{
display: block; /* to remove extra space below image */
}
</style>
</head>
<body>
<button type="button" class="image-btn">
<img src="images/download-btn.png" width="250">
</button>
</body>
</html>
Related FAQ
Here are some more FAQ related to this topic: