CSS – Horizontally Center a Div
To horizontally center an inner div in an outer div using CSS, follow these instructions.
- Set a specific width for the inner div
- Set left and right margins as auto for the inner div.
background colors, height and padding are for demonstration purpose only. They are not part of the solution. We may modify these, or other properties as per requirement.
In this CSS Tutorial, we learned how to horizontally center an inner div in an outer div using CSS.