I want to set image to anchor tag but it is not working. Can anybody tell me what is wrong?
<a href="#" style="width:200px;height:100px;background:url('@Url.Content("~/Content/Images/facebook.png")');"></a>
Note: Don't pay attention to background. It is Asp.Net MVC syntax. But rest assured the image is loaded correctly. Can anybody tell me what am I doing wrong? If I type something in anchor tag it works fine. But I don't want to type anything开发者_如何学Go.
You need to either set the display property to block or inline-block for the link
<a href="#" style="display:block; width:200px;height:100px; ...
Links are inline by default.
Because a link is an inline element, it can't have width and height.
Set this attribute on it:
display: inline-block;
精彩评论