SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot Fruit & Veg's Avatar
    Join Date
    May 2000
    Location
    UK
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replacement for <center> tag

    I'm getting close to XHTML 1.0 validity.

    Just need my images to center on the page, but <center> is not valid. I've checked out w3schools.com (very good resource btw) but they have horizontal-text and vertical-image CSS tags but no horizontal-image related tags - how is this done?

    I've tried putting align="center" in the img tag but this is frowned upon too.
    USBtastic - UK Gadgets Blog
    SmartGeezer - UK Men's Clothing Blog
    Individualitee - Great Tshirts
    Shiola - Complete Waste of Time

  2. #2
    3MTA3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    1,016
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try CSS and use "text-align: center;" in the table cell. If you're not using tables then you could put it in a <div> tag.

  3. #3
    SitePoint Addict eskuel's Avatar
    Join Date
    Apr 2003
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <div align="center"> still validates for some reason, I thought it had been depreciated.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by eskuel
    <div align="center"> still validates for some reason, I thought it had been depreciated.
    It validates as XHTML 1.0 Transitional, because Transitional lets you use deprecated attributes. Deprecated means "not officially in but still supported", while in XHTML Strict attributes like bgcolor and align aren't supported for most elements .

    Anyway, to answer the original question:
    Code:
    img.cen {
      display: block;
      margin: auto;
    }
    HTML Code:
    <img class="cen" src="myimage.gif" height="30" width="400" alt="Help me" />

  5. #5
    SitePoint Zealot Fruit & Veg's Avatar
    Join Date
    May 2000
    Location
    UK
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That code works for me in Firebird but not in IE6.

    This isn't the first time I've come across differences in XHTML between browsers which makes me feel suicidal, as I thought the point of it was to be cross browser compatible.
    USBtastic - UK Gadgets Blog
    SmartGeezer - UK Men's Clothing Blog
    Individualitee - Great Tshirts
    Shiola - Complete Waste of Time

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    suicidal? hey, it's not your fault

    most web developers feel homicidal, particularly towards browser manufacturers whose browsers disregard standards
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •