align a image in xhtml ( center ? )

Discussion in 'HTML' started by Mark Strain, Jan 25, 2005.

  1. Mark Strain

    Mark Strain Guest

    can any one tell me how to align an image to the centre of the page using
    xhtml. i've tryed

    <p><img src="my pic" align="middle"/></p>

    the pic still is displayed on the left and not in the centre -
    im told you cant use the center tag in xhtml
    Mark Strain, Jan 25, 2005
    #1
    1. Advertising

  2. Mark Strain wrote:

    > can any one tell me how to align an image to the centre of the page using
    > xhtml. i've tryed
    >
    > <p><img src="my pic" align="middle"/></p>
    >
    > the pic still is displayed on the left and not in the centre -
    > im told you cant use the center tag in xhtml
    >
    >
    >


    Hmm.. <div align="center"><img src="your pic"></div> I don't know other
    ways. Align in picture is for text around picture.

    --
    --
    http://www.technologycommunity.com/
    Matti Kiviharju, Jan 25, 2005
    #2
    1. Advertising

  3. Mark Strain

    Richard Guest

    On Tue, 25 Jan 2005 18:51:12 GMT Mark Strain wrote:

    > can any one tell me how to align an image to the centre of the page
    > using
    > xhtml. i've tryed


    > <p><img src="my pic" align="middle"/></p>


    > the pic still is displayed on the left and not in the centre -
    > im told you cant use the center tag in xhtml


    <p style="text-align:center">
    <p style="margin:nn%>
    where nn is an appropriate number.

    align="middle" is purely for tables.
    Richard, Jan 25, 2005
    #3
  4. Mark Strain

    Steve Pugh Guest

    "Richard" <Anonymous@127.001> wrote:
    >On Tue, 25 Jan 2005 18:51:12 GMT Mark Strain wrote:
    >
    >> can any one tell me how to align an image to the centre of the page
    >> using xhtml. i've tryed
    >>
    >> <p><img src="my pic" align="middle"/></p>


    Which shouldn't work in HTML or XHTML (see below). But some browsers
    may guess what you mean, some of the time.

    >> the pic still is displayed on the left and not in the centre -
    >> im told you cant use the center tag in xhtml


    You can in XHTML 1.0 Transitional.
    You can't in XHTML 1.0 Strict or XHTML 1.1 (nor in HTML 4/4.01
    Strict).

    CSS is the way to go, the exact code would depend on what you content
    really is but the first of the three examples given by RtS will, most
    surprisingly, work in many cases.

    ><p style="text-align:center">


    Wow. That's actually correct syntax and will centre the image. But,
    and this is a question for the OP, is a single image really a
    paragraph?

    ><p style="margin:nn%>
    >where nn is an appropriate number.


    Only if the image itself has a % width. Because margin: 30%; with a
    200px wide image will only be centred if the window is exactly 500px
    wide. Also margin: 0 30%; would make more sense

    >align="middle" is purely for tables.


    No it's not. The only elements for which align="middle" is valid are
    APPLET, IFRAME, IMG, INPUT and OBJECT where it aligns the element to
    the vertical middle of the line which contains it.

    The align attribute of tables can take the values left, center or
    right. Perhaps you're confused with the valign attribute of certain
    table child elements?

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Jan 25, 2005
    #4
  5. Mark Strain

    Sid Ismail Guest

    On Tue, 25 Jan 2005 19:24:44 GMT, Matti Kiviharju
    <> wrote:

    : Align in picture is for text around picture.

    That's changed - use CSS.

    Sid
    Sid Ismail, Jan 25, 2005
    #5
  6. Mark Strain

    Sid Ismail Guest

    On Tue, 25 Jan 2005 21:16:58 +0000, Steve Pugh <> wrote:

    : The align attribute of tables can take the values left, center or
    : right. Perhaps you're confused with the valign attribute of certain
    : table child elements?

    ALIGN=top|middle|bottom|left|right (image alignment)
    from: http://www.htmlhelp.com/reference/html40/special/img.html

    I use middle often when e.g. there are 3 images horizontally for instance
    and you want to align them in the "middle" not on the baseline and thus
    avoiding a skyscraper effect.

    Sid
    Sid Ismail, Jan 26, 2005
    #6
  7. Mark Strain

    Steve Pugh Guest

    Sid Ismail <> wrote:
    >On Tue, 25 Jan 2005 21:16:58 +0000, Steve Pugh <> wrote:
    >
    >: The align attribute of tables can take the values left, center or
    >: right. Perhaps you're confused with the valign attribute of certain
    >: table child elements?
    >
    >ALIGN=top|middle|bottom|left|right (image alignment)
    >from: http://www.htmlhelp.com/reference/html40/special/img.html


    Yes? You're just repeating a part of my post that you snipped.
    "The only elements for which align="middle" is valid are
    APPLET, IFRAME, IMG, INPUT and OBJECT where it aligns the element to
    the vertical middle of the line which contains it."

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Jan 26, 2005
    #7
  8. Mark Strain

    Sid Ismail Guest

    On Wed, 26 Jan 2005 09:38:43 +0000, Steve Pugh <> wrote:

    : Sid Ismail <> wrote:
    : >On Tue, 25 Jan 2005 21:16:58 +0000, Steve Pugh <> wrote:
    : >
    : >: The align attribute of tables can take the values left, center or
    : >: right. Perhaps you're confused with the valign attribute of certain
    : >: table child elements?
    : >
    : >ALIGN=top|middle|bottom|left|right (image alignment)
    : >from: http://www.htmlhelp.com/reference/html40/special/img.html
    :
    : Yes? You're just repeating a part of my post that you snipped.
    : "The only elements for which align="middle" is valid are
    : APPLET, IFRAME, IMG, INPUT and OBJECT where it aligns the element to
    : the vertical middle of the line which contains it."


    The OP said:
    <p><img src="my pic" align="middle"/></p>

    I was saying that middle is a valid attribute for image.

    Your previous post confirmed it and said that middle is not valid for
    _Tables_. Humble apologies.

    Sid
    Sid Ismail, Jan 26, 2005
    #8
  9. Mark Strain

    Mark Strain Guest

    thanks for the help - gone to try and learn how to di it on css
    >
    >
    >
    Mark Strain, Jan 26, 2005
    #9
  10. Mark Strain

    spiresvideo

    Joined:
    Jan 10, 2009
    Messages:
    1
    CSS Float

    Use float:left in your CSS to replace align="left" in an img tag for XHTML 1.0 Strict validity.
    spiresvideo, Jan 10, 2009
    #10
    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,125
  2. tshad

    text-align vs align

    tshad, Jun 23, 2005, in forum: HTML
    Replies:
    1
    Views:
    1,234
    David Dorward
    Jun 23, 2005
  3. Beck
    Replies:
    3
    Views:
    893
    David Dorward
    Nov 11, 2005
  4. Paul Lautman

    left align within centre align

    Paul Lautman, Mar 3, 2006, in forum: HTML
    Replies:
    3
    Views:
    553
    Paul Lautman
    Mar 3, 2006
  5. Steve Richter
    Replies:
    1
    Views:
    876
    Mark Rae
    Jun 24, 2007
Loading...

Share This Page