Center the child elements of a div box by using the box-align and box-pack properties together:
![]()
The box-pack property is not supported in any of the major browsers.
Internet Explorer 10 supports an alternative, the -moz-flex-pack property.
Firefox supports an alternative, the -moz-box-pack property.
Safari, Opera, and Chrome support an alternative, the -webkit-box-pack property.
Note: Flexible boxes are not supported in Internet Explorer 9 and earlier versions.
The box-pack property specifies where child elements of a box are placed when the box is larger than the size of the children.
This property specifies the horizontal position in horizontal boxes, and the vertical position in vertical boxes.
| Default value: | start |
|---|---|
| Inherited: | no |
| Version: | CSS3 |
| JavaScript syntax: | object.style.boxPack="center" |
| Value | Description | Play it |
|---|---|---|
| start | For normal direction boxes, the left edge of the first child is placed at the left side (all extra space is placed after the last child). For reverse direction boxes, the right edge of the last child is placed at the right side (all extra space is placed before the first child) | Play it » |
| end | For normal direction boxes, the right edge of the last child is placed at the right side (all extra space is placed before the first child). For reverse direction boxes, the left edge of the first child is placed at the left side (all extra space is placed after the last child) | Play it » |
| center | Extra space is divided evenly, with half placed before the first child and the other half placed after the last child | Play it » |
| justify | Extra space is divided evenly between each child (no extra space before the first child or after the last child) | Play it » |
Your message has been sent to W3Schools.