align="left" in CSS for images

F

Fabian

Hi,

I don't know how to search for it with Google so I'll ask it here. I know
how to insert images in html (xhtml 1.0) (<img src="blabla.jpg"
style="width: ..px; height: ..px">) but I don't know how to align the image.

In old html it was align="left" but how should I do this in CSS? Is it
something with vertical-align now?
 
A

Andy Holmes

Fabian said:
Hi,

I don't know how to search for it with Google so I'll ask it here. I know
how to insert images in html (xhtml 1.0) (<img src="blabla.jpg"
style="width: ..px; height: ..px">) but I don't know how to align the image.

In old html it was align="left" but how should I do this in CSS? Is it
something with vertical-align now?

What you want is probably something like:

<img src="foo.gif" style="display: block; margin-left: 0; margin-right:
auto;"/>

Or:

<div style="test-align: left;">
<img src="foo.gif"/>
</div>

But the second example will align any inline content (ie. text, other
images) to the left as well.

Hope that helps.

-Andy
 
D

David Dorward

Fabian said:
I don't know how to search for it with Google so I'll ask it here. I know
how to insert images in html (xhtml 1.0) (<img src="blabla.jpg"
style="width: ..px; height: ..px">)

You missed the alt attribute. Its been required in all versions of HTML
published since about 1996.
but I don't know how to align the image.

In old html it was align="left" but how should I do this in CSS?

Look up the "float" property, or see text-align on the container for true
alignment (which has nothing to do with the obsolete align attribute).

http://w3.org/TR/CSS2/
Is it something with vertical-align now?

That can align the image vertically on a line.
 
F

Fabian

David said:
You missed the alt attribute. Its been required in all versions of
HTML published since about 1996.


Look up the "float" property, or see text-align on the container for
true alignment (which has nothing to do with the obsolete align
attribute).

http://w3.org/TR/CSS2/


That can align the image vertically on a line.

Thanks. I used float and it works perfect.
(And on sites I usely don't forget Alt-tags and if I forget them, I see it
when I validate, but thanks for reminding me, I just wanted to give an
example here and was a bit too quick!)

Thanks both Andy and David!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top