Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML's "<img align=top>" in CSS?

How do I emulate

<img align='top' src='huge_image.jpg'>
<span>I start at the top right corner of the image!</span>

in CSS?

Maybe it's embarrassingly simple, but I really don't know.

like image 396
Pekka Avatar asked Nov 12 '09 23:11

Pekka


4 Answers

float: left will position it such that the img element will be to the left of the span, but if you are wanting to replicate align="top" because of the vertical alignment issue (span at bottom right vs. top right), then try style="vertical-align: top;"

like image 195
ddango Avatar answered Sep 26 '22 11:09

ddango


It depends on the container of your elements. The vertical-align CSS property doesn't exactly map to the valign attribute. I recommend checking this link out for an explanation on how to achieve this with CSS. http://phrogz.net/CSS/vertical-align/index.html

like image 20
Chris Avatar answered Sep 24 '22 11:09

Chris


I think you're looking for the vertical-align CSS property.

<img style="vertical-align: top;" alt="blah" src="blah.jpg" />

Ideally you wouldn't just slap it directly on the <img> tag, but instead use a CSS class.

like image 35
Zack The Human Avatar answered Sep 24 '22 11:09

Zack The Human


<style="text/css">

.top_aligned_image {vertical-align: top; /* or text-top, I can't remember for sure which works better */}

</style>

<img class="top_aligned_image" src='huge_image.jpg' /><span>I start at the top right corner of the image!</span>

Should do it.

like image 20
David Thomas Avatar answered Sep 25 '22 11:09

David Thomas