Steps: To align HTML element horizontally Center:
- Step1:Please keep in mind that the black level element takes full available width.
- Step2: Assigning a constant width value of the block-level element prevents it from stretching out to the edge of the container. Now, assign margin: auto; property to the block element. In this case, the block-level element is aligned horizontally center, and the remaining empty space divided equally into the left and right margins.
General Syntax For Center Alignment Of Block Level Element
Note:The HTML element can be aligned either horizontal or vertical. The horizontal alignment will be left, center and right while vertical alignment will be top, bottom, and center.