---
title: "How do I center block-elements with CSS1?"  
description: "How do I center block-elements with CSS1?"  
author: "Anonymous User"  
published: 2012-12-13  
updated: 2012-12-13  
canonical: https://www.mindstick.com/forum/492/how-do-i-center-block-elements-with-css1  
category: "css-css3"  
tags: ["css-css3"]  
reading_time: 2 minutes  

---

# How do I center block-elements with CSS1?

Hello every one \
\
In the last week, i googly about center [block](https://www.mindstick.com/forum/157599/explain-the-process-control-block-pcb-in-the-operating-system) - element in CSS. so my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is that h**ow do I center block-[elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) with CSS1?**\
\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by AVADHESH PATEL

Hi Goti Bandu\
\
**There 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.


---

Original Source: https://www.mindstick.com/forum/492/how-do-i-center-block-elements-with-css1

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
