Home >Web Front-end >CSS Tutorial >How Do I Horizontally Center a Div in CSS?
Question:
How do I center a
Problem:
Setting text-align: center; on the
Answer:
Horizontal Centering for Block Elements
For block elements (like
This sets top and bottom margins to 0 and left and right margins to auto of the same size. The element will be centered automatically, given that it has a known width.
Horizontal Centering for Inline Elements
The above is the detailed content of How Do I Horizontally Center a Div in CSS?. For more information, please follow other related articles on the PHP Chinese website!