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-align 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 »
More examples at the bottom of this page.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

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

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

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


Definition and Usage

The box-align property specifies how to align the child elements of a box.

Default value: stretch
Inherited: no
Version: CSS3
JavaScript syntax: object.style.boxAlign="center"


Syntax

box-align: start|end|center|baseline|stretch;

Value Description Play it
start For normal direction boxes, the top edge of each child is placed along the top of the box. For reverse direction boxes, the bottom edge of each child is placed along the bottom of the box Play it »
end For normal direction boxes, the bottom edge of each child is placed along the bottom of the box. For reverse direction boxes, the top edge of each child is placed along the top of the box Play it »
center Any extra space is divided evenly, with half placed above the child and the other half placed below the child Play it »
baseline If box-orient is inline-axis or horizontal, all children are placed with their baselines aligned Play it »
stretch The child elements are stretched to fill the containing block


Examples

Try it Yourself - Examples

Change the box-align value for an element
This example demonstrates how to use a JavaScript to change the box-align values for an element.


CSS Reference Complete CSS Reference
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
XML Editor - Free Trial!
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