Hello every one
In the last week, i googly about center block - element in CSS. so my question is that how do I center block-elements with CSS1?
Thanks in advance
How do I center block-elements with CSS1?
242613-Dec-2012
Home / DeveloperSection / Forums / How do I center block-elements with CSS1?
AVADHESH PATEL
13-Dec-2012There are two ways of centering block level elements:
1. By setting the properties margin-left and margin-right to auto and width to some explicit value: BODY {width: 30em; background: cyan;} P {width: 22em; margin-left: auto; margin-right: auto} In this case, the left and right margins will each be four ems wide, since they equally split up the eight ems left over from (30em - 22em). Note that it was not necessary to set an explicit width for the BODY element; it was done here to keep the math clean.
2. Another example: TABLE {margin-left: auto; margin-right: auto; width: 400px ;} in most legacy browsers, a table's width is by default determined by its content. In CSS-conformant browsers, the complete width of any element (including tables) defaults to the full width of its parent element's content area. As browser becomes more conformance, authors will need to be aware of the potential impact on their designs.
I hope your googly stoped here.