How can I center something if I don't know ahead of time what the width is?

Posted by zeckdude on Stack Overflow See other posts from Stack Overflow or by zeckdude
Published on 2009-06-08T07:50:43Z Indexed on 2010/05/14 2:14 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

I am trying to center a paragraph tag with some text in it within a div, but I can't seem to center it using margin: 0 auto without having to specify a fixed width for the paragraph. I don't want to specify a fixed width, because I will have dynamic text coming into the paragraph tag and it will always be a different width based on how much text it is.

Does anyone know how I can center the paragraph tag within the div without having to specify a fixed width for the paragraph or without using tables?

© Stack Overflow or respective owner

Related posts about center

Related posts about css