css horizontal centering problem in html

Discussion in 'HTML' started by Thad, Feb 24, 2007.

  1. Thad

    Thad Guest

    page problem: index.html

    Located at www.imagedgifts.html

    The problem is centering(horizontally) the button and table. I've validated
    the page in w3c for html and css. I've even html tidied it(hope I said that
    right). For the life of me I cannot get the table and button centered
    horizontally in foxfire. It works just fine in IE though. Any suggestions
    would be appreciated.

    Thanks.
    Thad, Feb 24, 2007
    #1
    1. Advertising

  2. Thad wrote :
    > page problem: index.html
    >
    > Located at www.imagedgifts.html


    Do you mean located at http://www.imagedgifts.com/ ?


    > The problem is centering(horizontally) the button and table. I've validated
    > the page in w3c for html and css.


    Good! I would recommend you to use a strict DTD instead of transitional
    since your page is new.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    I've even html tidied it(hope I said that
    > right).


    I recommend HandCoder 0.3.4
    http://fabiwan.kenobi.free.fr/HandCoder/

    and to get the latest Tidy at
    http://dev.int64.org/tidy.html

    Tidy Quick Reference:
    http://tidy.sourceforge.net/docs/quickref.html

    > For the life of me I cannot get the table and button centered
    > horizontally in foxfire.


    foxfire ? Do you mean Firefox ?

    > It works just fine in IE though. Any suggestions
    > would be appreciated.


    Solution:

    #tbl1, #a1 {margin-left: auto; margin-right: auto;}

    More info:

    Interactive demo on CSS horizontal alignment and horizontal formating
    (when to use margin-left, margin-right and when to use text-align):
    http://www.gtalbot.org/NvuSection/NvuWebDesignTips/HorizontalAlignment.html

    Reference: CSS 1 horizontal formating (margin property) says: "if both
    'margin-left' and 'margin-right' are 'auto', they will be set to equal
    values. This will center the element inside its parent."

    Reference: CSS 1 text-align property says: "The [text-align] property
    describes how text (and inline elements) is aligned within the element."

    Using Web Standards in your webpages
    Section 2.2.3.2: I use <center> or align="center". How to align with CSS?
    http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages

    Also
    Centring using CSS by D. Dorward
    http://dorward.me.uk/www/centre/

    GĂ©rard
    --
    Using Web Standards in your Web Pages (Updated Dec. 2006)
    http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages
    =?ISO-8859-1?Q?G=E9rard_Talbot?=, Feb 24, 2007
    #2
    1. Advertising

  3. Thad

    Thad Guest


    > Thad wrote :
    >> page problem: index.html
    >>
    >> Located at www.imagedgifts.html

    >
    > Do you mean located at http://www.imagedgifts.com/ ?


    Didn't know there was a differance, but buy all good intentions, I did mean
    http://www.imagedgifts.com/ . Good point.



    > Good! I would recommend you to use a strict DTD instead of transitional
    > since your page is new.
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >


    I will take that into consideration. tyvm


    > foxfire ? Do you mean Firefox ?


    Yes...I shall just start abreviating as FF so I don't make the same mistake
    later. tyvm

    >
    >> It works just fine in IE though. Any suggestions would be appreciated.

    >
    > Solution:
    >
    > #tbl1, #a1 {margin-left: auto; margin-right: auto;}
    >

    From what I've read, I must have been daydreaming through those
    sections...thanks for pointing that out.

    Hey Gerald, your help is greatly appreciated.

    Thad
    Thad, Feb 24, 2007
    #3
    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. Tomas
    Replies:
    3
    Views:
    789
    Tomas
    Oct 31, 2003
  2. Sentient Fluid

    Centering horizontal 'button' menu

    Sentient Fluid, Jan 2, 2005, in forum: HTML
    Replies:
    6
    Views:
    671
  3. Carolyn Marenger

    centering and padding in horizontal menu

    Carolyn Marenger, Mar 19, 2006, in forum: HTML
    Replies:
    7
    Views:
    859
    Jonathan N. Little
    Mar 20, 2006
  4. bizshop

    CSS Text Centering Problem

    bizshop, Sep 17, 2007, in forum: HTML
    Replies:
    4
    Views:
    360
    Beauregard T. Shagnasty
    Sep 17, 2007
  5. Jeff
    Replies:
    1
    Views:
    346
    miher
    Mar 4, 2009
Loading...

Share This Page