CSS Alignment
CSS Alignment is used to align horizontally, vertically, or center. The horizontal alignment will be in the left, center and right & vertical alignment will be in the top, bottom, and center.
Center Alignment
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
Statement
.center {width:80%;margin:auto;}
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.