Center align a DIV without <center> tags

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DiamondEagle

    Center align a DIV without <center> tags

    Is there a way to center the following div without using the <center>
    tags?

    <body bgcolor="#FFFFF F">
    <center>
    <div id="Test" style="backgrou nd-color:#000000; color:#ffffff; width:
    80%; text-align:center; line-height:100px;"> Hello</div>
    </center>
    </body>

    I want the div AND the text in the div to be aligned to the center.

    Thanks...

    (It's probably REALLY simple and I'll be quite embarassed that I
    asked... but it's been one of "THOSE" days...)
  • Steve Pugh

    #2
    Re: Center align a DIV without &lt;center&g t; tags

    On Jun 18, 2:43 pm, DiamondEagle <and...@webmail .co.zawrote:
    Is there a way to center the following div without using the <center>
    tags?
    >
    <body bgcolor="#FFFFF F">
    1. Use CSS not HTML attributes.
    2. Set foreground and background colours together to avoid clashes
    with user defaults.
    <center>
    <div id="Test" style="backgrou nd-color:#000000; color:#ffffff; width:
    80%; text-align:center; line-height:100px;"> Hello</div>
    </center>
    </body>
    >
    I want the div AND the text in the div to be aligned to the center.
    It's not 100% obvious and hence it is a FAQ. Set margin-left and
    margin-right to auto.

    Make sure that your doctype is triggering standards mode or IE won't
    co-operate.

    Steve

    Comment

    • dorayme

      #3
      Re: Center align a DIV without &lt;center&g t; tags

      In article
      <13ba6d07-04fe-448d-8734-611c82d5d4a7@34 g2000hsf.google groups.com>,
      DiamondEagle <andyza@webmail .co.zawrote:
      Is there a way to center the following div without using the <center>
      tags?
      >
      The first two pages of

      <http://netweaver.com.a u/centring/>

      should give you a good idea of how to do both these things.

      --
      dorayme

      Comment

      • Ed Jay

        #4
        Re: Center align a DIV without &lt;center&g t; tags

        dorayme scribed:
        >In article
        ><13ba6d07-04fe-448d-8734-611c82d5d4a7@34 g2000hsf.google groups.com>,
        DiamondEagle <andyza@webmail .co.zawrote:
        >
        >Is there a way to center the following div without using the <center>
        >tags?
        >>
        >
        >The first two pages of
        >
        ><http://netweaver.com.a u/centring/>
        >
        >should give you a good idea of how to do both these things.
        That seems like a very helpful site. Is there a navigation page? The home
        page seems to have only a mail form.

        --
        Ed Jay (remove 'M' to reply by email)

        Win the War Against Breast Cancer.
        Knowing the facts could save your life.

        Comment

        • dorayme

          #5
          Re: Center align a DIV without &lt;center&g t; tags

          In article <jiij54dac3jgod iadghr9mjgv7ea1 m37oe@4ax.com>,
          Ed Jay <edMbj@aes-intl.comwrote:
          dorayme scribed:
          >
          In article
          <13ba6d07-04fe-448d-8734-611c82d5d4a7@34 g2000hsf.google groups.com>,
          DiamondEagle <andyza@webmail .co.zawrote:
          Is there a way to center the following div without using the <center>
          tags?
          >
          The first two pages of

          <http://netweaver.com.a u/centring/>

          should give you a good idea of how to do both these things.
          >
          That seems like a very helpful site. Is there a navigation page? The home
          page seems to have only a mail form.
          The things on this server are mainly just sets of self-contained pages.
          This set seems short enough not to need a menu but if I grow it, I guess
          I will put some navigation beyond the pages menu at top and bottom.

          I am a bit worried at the slightly artificial connection of things under
          the topic of centring in this set. What else should I put?

          * My views on the aesthetics of centring?

          * My take on why centring has such an appeal (I reckon it has to do
          with the importance of left/right symmetry in animal evolution)?

          * Perhaps an attempt at humorous, maybe even florid writing, about why
          archery targets have the bull's eye in the centre; after all, even a
          bull does not have its eye in the dead centre of its bulk, neither
          mass-fully nor geometrically speaking? And besides, it has two eyes.

          * Why don't dart boards have two bulls eyes like bulls, you could get
          100 only if you can throw two darts at once each landing on different
          eyes? Perhaps I could make and market a special and more rational
          dart-board, closer to bull. (psst, Boji, wanna send me some $buckeroos
          as an advance payment for one of these?)

          --
          dorayme

          Comment

          Working...