The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Centering an Item

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #28431

    Hi there,

    I’ve been working on my site for a day now and I can’t seem to figure out how to center a box. PLease advised.

    the link is.

    (if you scroll down to "contact us" and "what we provide", I can’t seem to center the box) (this explains what i mean)

    thanks guys for helping me out.


    thanks for the help guys! quick question, why did that tag work?


    margin: 0 auto;

    is the same as:

    margin: 0 auto 0 auto;

    is the same as:

    margin-top: 0;
    margin-bottom: 0;
    margin-left: auto;
    margin-right: auto;

    What it’s saying is, making the top and bottom margin zero (or whatever number you like, it has no change on it being centered). And then for the left and right margins, automatically even them out, depending on what size window the user has.


    Hey gang,

    I’ve been struggling with centering an image that uses Brian Revis’ "captify" script for img captions. It’s very clean and I like it, but Captify has its own set of css attributes, which I try not to tinker with. One of those is margin: 0 and a wrapper class that floats left. I took out the latter, finding that it didn’t seem to mess anything up.

    I’ve built a site for my sister-in-law, which you can see here:

    On the About page (, I had to right-align a captified-image. I got that to work by creating a div around the image and floating the div right. Worked great. However, on the Puppies page ( I have to center the puppy pic. I tried the same approach, created a div to surround the img tag. Instead of float right, I said margin-left: auto and margin-right: auto. No dice. The image kept hugging the left side of the page. I could not center the image… UNTIL I specified a width of 400px (the image’s width) on my wrapper div. (centered-photo)

    My question: WHY? I really don’t want to leave a specific width on that centered-photo div. Can you guys see something that’s causing that img within the div to stay left when you remove the width specification? Use firebug and disable the width: 400px on centered-photo to see what I mean.

    THANKS for any help or advice!
    -Greg in CT

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.