align="left" in CSS for images

Discussion in 'HTML' started by Fabian, Oct 20, 2003.

  1. Fabian

    Fabian Guest

    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?

    --
    Fabian
    http://givelove.be/
    Fabian, Oct 20, 2003
    #1
    1. Advertising

  2. Fabian

    Andy Holmes Guest

    Fabian wrote:
    > 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
    Andy Holmes, Oct 20, 2003
    #2
    1. Advertising

  3. Fabian wrote:

    > 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.




    --
    David Dorward http://dorward.me.uk/
    David Dorward, Oct 20, 2003
    #3
  4. Fabian

    Fabian Guest

    David Dorward wrote:
    > Fabian wrote:
    >
    >> 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.


    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!

    --
    Fabian
    http://givelove.be/
    Fabian, Oct 21, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kay
    Replies:
    2
    Views:
    7,149
  2. jersie0
    Replies:
    6
    Views:
    19,500
    Toby A Inkster
    Nov 16, 2003
  3. Paul Lautman

    left align within centre align

    Paul Lautman, Mar 3, 2006, in forum: HTML
    Replies:
    3
    Views:
    574
    Paul Lautman
    Mar 3, 2006
  4. Jon Slaughter

    left and right align to images in a div

    Jon Slaughter, Apr 13, 2007, in forum: HTML
    Replies:
    25
    Views:
    910
    Neredbojias
    Apr 28, 2007
  5. =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=

    Help on table align on left of page vs left hanging indent

    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jul 10, 2007, in forum: XML
    Replies:
    2
    Views:
    1,000
    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=
    Jul 16, 2007
Loading...

Share This Page