W3Schools.com

CSS Reference

CSS Reference
CSS Selectors
CSS Reference Aural
CSS Web Safe Fonts
CSS Units
CSS Colors
CSS Color Values
CSS Color Names
CSS Color HEX
CSS3 Browser Support

CSS Properties

CSS3 box-pack Property

CSS Reference Complete CSS Reference

Example

Center the child elements of a div box by using the box-align and box-pack properties together:

div
{
width:350px;
height:100px;
border:1px solid black;

/* Firefox */
display:-moz-box;
-moz-box-orient:horizontal;
-moz-box-pack:center;
-moz-box-align:center;

/* Safari and Chrome */
display:-webkit-box;
-webkit-box-orient:horizontal;
-webkit-box-pack:center;
-webkit-box-align:center;

/* W3C */
display:box;
box-orient:horizontal;
box-pack:center;
box-align:center;
}

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The box-pack property is not supported in any of the major browsers.

Firefox supports an alternative, the -moz-box-pack property.

Safari and Chrome support an alternative, the -webkit-box-pack property.


Definition and Usage

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"


Syntax

box-pack: start|end|center|justify;

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 »


CSS Reference Complete CSS Reference

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE