ofer dofer
ofer dofer

Reputation: 621

Text next to a link image

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

Answers (1)

jeffjenx
jeffjenx

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

Related Questions