Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
This is a property of the original CSS Flexible Box Layout Module draft, and has been replaced by a newer standard. See flexbox for information about the current standard.
The box-orient
CSS property specifies whether an element lays out its contents horizontally or vertically.
/* Keyword values */ box-orient: horizontal; box-orient: vertical; box-orient: inline-axis; box-orient: block-axis; /* Global values */ box-orient: inherit; box-orient: initial; box-orient: unset;
For example, XUL box
and hbox
elements lay out their contents horizontally by default, but XUL vbox
elements lay out their contents vertically by default.
HTML DOM elements lay out their contents along the inline-axis by default. This CSS property will only apply to HTML elements with a CSS display
value of box
or inline-box
.
Initial value | inline-axis (horizontal in XUL) |
---|---|
Applies to | elements with a CSS display value of box or inline-box |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
The box-orient
property is specified as one of the keyword values listed below.
Values
horizontal
- The box lays out its contents horizontally.
vertical
- The box lays out its contents vertically.
inline-axis
(HTML)- The box displays its children along the inline axis.
block-axis
(HTML)- The box displays its children along the block axis.
The inline and block axes are the writing-mode dependent keywords which, in English, map to horizontal
and vertical
respectively.
Formal syntax
horizontal | vertical | inline-axis | block-axis | inherit
Examples
<!DOCTYPE html> <html> <head> <title>CSS box-orient example</title> <style> div.example { display: -moz-box; /* Mozilla */ display: -webkit-box; /* WebKit */ display: box; /* As specified */ /* Children should be oriented vertically */ -moz-box-orient: horizontal; /* Mozilla */ -webkit-box-orient: horizontal; /* WebKit */ box-orient: horizontal; /* As specified */ } </style> </head> <body> <div class="example"> <p>I will be to the left of my sibling.</p> <p>I will be to the right of my sibling.</p> </div> </body> </html>
The box-orient
property will cause the above two <p>
sections in the example to display in the same line, as shown here:
Notes
For XUL elements, if the orientation is set using the element's orient
attribute, then the style is ignored.
Specifications
- Flexible Box Layout Module (W3C Working Draft) Note: The current state of this specification does not reflect Mozilla's or WebKit's older implementations.
- Old Flexible Box Layout Module Note: Mozilla and WebKit's implementations used to reflect this version of the specification.
Browser compatibility
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Yes)-webkit | (Yes)-webkit | (Yes)-moz[1] | No support | (Yes)-webkit | 1.1-khtml 3.0-webkit |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | ? | ? | (Yes)-webkit | (Yes) -moz[1] | No support | ? | 1.0-webkit |
[1] In addition to the -moz
prefixed support, Gecko 48.0 (Firefox 48.0 / Thunderbird 48.0 / SeaMonkey 2.45) added support for a -webkit
prefixed version of the property for web compatibility reasons behind the preference layout.css.prefixes.webkit
, defaulting to false
. Since Gecko 49.0 (Firefox 49.0 / Thunderbird 49.0 / SeaMonkey 2.46) the preference defaults to true
.