Reputation: 135
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>
Upvotes: 0
Views: 1238
Reputation: 1
It is because the button image isnt linked to the href correctly and the "a" isnt closed correctly
I use:
<a href="link or image">
<img src="yourimage.png">
</a>
IT WORKS!!
Upvotes: 0
Reputation: 446
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("");
}
Upvotes: 1
Reputation: 1
I think the problem is that you are using the button. Try this:
<a href="" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</a>
Upvotes: 0