CSS - box-orient

Example

 

HTML
<!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:

example.png

Syntax  

CSS
/* 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;

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

CSS
horizontal <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> vertical <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> inline-axis <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> block-axis <a title="Single bar" href="css/value_definition_syntax#single_bar">|</a> inherit

Description  

The CSS box-orient property specifies whether an element lays out its contents horizontally or vertically. See Flexbox for more about the properties of flexbox elements.

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 valueinline-axis (horizontal in XUL)
Applies toelements with a CSS display value of box or inline-box
Inheritedno
Mediavisual
Computed valueas specified
Animatableno
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Browser Compatibility  

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes)-webkit (Yes)-moz[1] No support (Yes)-webkit 1.1-khtml
3.0-webkit
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? (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.

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 implementation.

Old Flexible Box Layout Module

Note: WebKit and Mozilla's implementations reflect this version of the specification.

 

box-direction, box-pack, box-align, flex-direction

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/box-orient

CSS NeedsBrowserCompatibility NeedsMobileBrowserCompatibility Non-standard Reference