Centering image without <center>

Discussion in 'HTML' started by fantababy, Apr 21, 2006.

  1. fantababy

    fantababy Guest

    How to center an image?

    1. without using <center>

    2. using valid w3c compliant xhtml / css

    3. which works in both IE and firefox

    Please share your knowledge. Thanx.
    fantababy, Apr 21, 2006
    #1
    1. Advertising

  2. fantababy wrote:
    > How to center an image?
    >
    > 1. without using <center>
    >
    > 2. using valid w3c compliant xhtml / css
    >
    > 3. which works in both IE and firefox
    >
    > Please share your knowledge. Thanx.
    >


    IMG { display: block; margin-left: auto; margin-right: auto; }


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 21, 2006
    #2
    1. Advertising

  3. fantababy

    dorayme Guest

    In article
    <>,
    "fantababy" <> wrote:

    > How to center an image?
    >
    > 1. without using <center>
    >
    > 2. using valid w3c compliant xhtml / css
    >
    > 3. which works in both IE and firefox
    >
    > Please share your knowledge. Thanx.



    You could take a look at
    http://www.netmechanic.com/news/vol7/html_no10.htm

    --
    dorayme
    dorayme, Apr 21, 2006
    #3
  4. fantababy

    Jim Moe Guest

    fantababy wrote:
    > How to center an image?
    >
    > 1. without using <center>
    > 2. using valid w3c compliant xhtml / css
    > 3. which works in both IE and firefox
    >

    p { text-align: center; }

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
    Jim Moe, Apr 21, 2006
    #4
  5. fantababy

    Neredbojias Guest

    To further the education of mankind, "fantababy" <>
    vouchsafed:

    > How to center an image?
    >
    > 1. without using <center>
    >
    > 2. using valid w3c compliant xhtml / css
    >
    > 3. which works in both IE and firefox
    >
    > Please share your knowledge. Thanx.


    Where's the image, -in a div, table, paragraph, etc.? Is there more than
    one image? Will text be associated with or affect the placement of the
    image?

    I don't often see just an image on a line with nothing else.

    --
    Neredbojias
    Infinity has its limits.
    Neredbojias, Apr 21, 2006
    #5
  6. fantababy wrote:

    > How to center an image?


    http://dorward.me.uk/www/centre/


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Apr 21, 2006
    #6
  7. fantababy

    Andy Dingley Guest

    Andy Dingley, Apr 21, 2006
    #7
  8. David Dorward, Apr 21, 2006
    #8
  9. fantababy

    ironcorona Guest

    Jonathan N. Little wrote:

    > IMG { display: block; margin-left: auto; margin-right: auto; }


    You could even just use
    img {display:block; margin:0 auto;}

    Which is just a shorter way of writing the above.
    ironcorona, Apr 21, 2006
    #9
  10. ironcorona wrote:
    > Jonathan N. Little wrote:
    >
    >> IMG { display: block; margin-left: auto; margin-right: auto; }

    >
    > You could even just use
    > img {display:block; margin:0 auto;}
    >
    > Which is just a shorter way of writing the above.
    >


    No, you have just set the top and bottom margins to 0. Mine leaves
    whatever the default value was alone.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 21, 2006
    #10
  11. fantababy

    ironcorona Guest

    Jonathan N. Little wrote:

    > No, you have just set the top and bottom margins to 0. Mine leaves
    > whatever the default value was alone.


    The default margin for an image IS 0
    ironcorona, Apr 21, 2006
    #11
  12. fantababy

    Andy Dingley Guest

    David Dorward wrote:
    > Andy Dingley wrote:


    > > IE is broken though.

    >
    > Not in Standards mode, and not when it comes to aligning inline content.


    vertical is still bust though, isn't it ?
    Andy Dingley, Apr 21, 2006
    #12
  13. Andy Dingley wrote:

    >>> IE is broken though.


    >> Not in Standards mode, and not when it comes to aligning inline content.


    > vertical is still bust though, isn't it ?


    Bust in what way? (And the question doesn't mention aligning to the vertical
    middle of anything anyway).

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Apr 21, 2006
    #13
  14. ironcorona wrote:
    > Jonathan N. Little wrote:
    >
    >> No, you have just set the top and bottom margins to 0. Mine leaves
    >> whatever the default value was alone.

    >
    > The default margin for an image IS 0


    Maybe, or many not, but it definitely will be with your code.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 21, 2006
    #14
    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. Jerry Camel

    Centering an image with text

    Jerry Camel, Sep 23, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    531
    John Timney \(ASP.NET MVP\)
    Sep 23, 2005
  2. Richard

    Re: Centering image on page?

    Richard, Jun 25, 2003, in forum: HTML
    Replies:
    0
    Views:
    3,753
    Richard
    Jun 25, 2003
  3. Jerry Muelver

    Re: Centering image on page?

    Jerry Muelver, Jun 25, 2003, in forum: HTML
    Replies:
    0
    Views:
    831
    Jerry Muelver
    Jun 25, 2003
  4. mr_vocab
    Replies:
    4
    Views:
    691
    mr_vocab
    May 24, 2004
  5. Samuël van Laere

    Image centering

    Samuël van Laere, Dec 5, 2004, in forum: HTML
    Replies:
    4
    Views:
    520
    David Dorward
    Dec 5, 2004
Loading...

Share This Page