Reputation: 621
I know how to put a text next to an image by applying float:left to the img tag, but when I give it a link e.g href="#"
the text won't stand stick to the image, it falls down. To give more info about the project, my <a>
tags in the <p>
tags are display: inline-block; and the css I applied to the img tags is:
float:left;
margin-right: 15px;
border:0px;
So why is this happening? I want my image to stand just as it does when I don't put it between <a>
tags.
Upvotes: 0
Views: 305
Reputation: 17457
The float: left;
means the element is floated to the left of the content within the same parent. Since you are wrapping the image inside of an <a></a>
tag, the image is being floated to the left of the content within the <a>
.
If you apply the float to the a
instead of the img
, then the a
will be floated to the left of the content in its parent, as desired.
Upvotes: 2