Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Centering in Firefox.

  1. #1
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Centering in Firefox.

    Hey, this is probably a very simple question for most of you super uber coders, and i feel stupid for asking this, but how do i center stuff in firefox? when i center stuff on my website it only centers for IE. =\ thanks.

  2. #2
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't think this is the 'proper' way, because <center> is depreciated.
    But if you just:

    HTML Code:
    <body>
    <center>
    ----content-----
    </center>
    </body>
    Then you'll have a centered web page. You can also use css:
    HTML Code:
    style="text-align:center;"

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    HTML Code:

    <body>
    <center>
    ----content-----
    </center>
    </body>
    The center element was deprecated in HTML 4.01.

    The center element is not supported in XHTML 1.0 Strict DTD.

    The deprecation of the <center> element done in favour of CSS.

  4. #4
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    HTML Code:
    <body style="text-align:center;">
    <div>
    ----content-----
    </div>
    </body>
    does not center the <div>. So i guess I'm with original poster here, how do you do it ?

  5. #5
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    <body>
    <div style="width:100&#37;;">
    <div style="text-align:center;">
    This is a test
    </div>
    </div>
    </body>
    The above code will do what you want.

    Checked it with IE 7 and Firefox 2.0.0.1

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You need to understand the difference. The <center> element does two things as seen from the perspective of CSS: it applies equal margins to both sides of the element and centres the text within that element.

    Code:
    <div style="margin: auto;">
    will do the former (although this will not be noticeable unless you also apply a fixed width to the element, since by default block-level elements take up all available width.
    Code:
    <div style="text-align: center;">
    will do the latter, but not affect the position of the <div> itself.
    Code:
    <div style="text-align: center; margin: auto;">
    will apply both styles and make the <div> behave as if it were <center>.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    As a simple attribute, you can just use:
    <div align="center">

    I'm pretty sure this is the same as <center>, so it would include both, but... not positive on that one.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Quote Originally Posted by djr33 View Post
    As a simple attribute, you can just use:
    <div align="center">

    I'm pretty sure this is the same as <center>, so it would include both, but... not positive on that one.
    The above code is deprecated one in favor of CSS based aligning methods.

  9. #9
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter View Post
    The above code is deprecated one in favor of CSS based aligning methods.
    When did that happen, the last time I tested that (about a month ago) it validated as XHTML 1.0 transitional without an issue.
    Thanks DD, you saved me countless times

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    XHTML Transitional is based on HTML 4.01 Transitional, which in turn is based on HTML 3.2. Great care has been taken to avoid progress in each lest something break.

    Just because it's valid Trans (of any format or version) doesn't necessarily mean it hasn't been deprecated in the real DOCTYPEs.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •