/

HTML / CSS / JavaScript Tutorial

CSS Property: order

[this page | pdf | back links]

The CSS (CSS3) order property indicates the order of a flexible item relative to other flexible items inside the same container.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

number

Integer

 

Default Value:

0

JavaScript syntax:

e.g. object.style.order="2"

Inherited:

No

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
.x1 {order: 3;}
</style>
</head>
<body>
Element with default property<br>
<div style="display: flex;">
<div>A</div><div>B</div><div>C</div>
</div>
<br>
Property set using in-file HTML style<br>
<div style="display: flex;">
<div class="x1">A</div><div>B</div><div>C</div>
</div>
<br>
Property set using JavaScript<br>
<div style="display: flex;">
<div id="x2">A</div><div>B</div><div>C</div>
</div>
<br>

<script>
document.getElementById("x2").style.order = "3";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyOrder() {
  var x = document.createElement("DIV"); x.style.order = "3"; return (window.getComputedStyle(x, null).order == "3");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile