htmlimagebuttonpng

Png image as html button


I would like to use an icon as a drobdown button on my navbar, but I am new to html and stuff, so I do not know where my snipplet fails:

<button type= "image" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</button>

Solution

  • In your case the issue is most likely with the source of the image. Check the path (where your image is located) and link it correctly.

    Example: src="../folder/folder/image.png"

    You can also add the image as a background with CSS like this:

    .dropbtn {
      background: url("");
    }