<div class="controls">
<select id="writingMode">
  <option value="horizontal-tb">horizontal-tb</option>
  <option value="vertical-lr">vertical-lr</option>
  <option value="vertical-rl">vertical-rl</option>

<div id="container">
<div class="box logical">
  <div class="floated"></div>
  The square in this box is floated inline-start and has a margin using logical properties.
<div class="box physical">
  <div class="floated"></div>
  The square in this box is floated left and has a margin using physical properties.
* { box-sizing: border-box; }

html {
  font: 1.2em Helvetica, sans-serif;

body {
  padding: 40px;
  background-color: #fff;
  color: rgb(108,91,123);
  display: flex;
  flex-direction: column;
  align-items: center;

.controls {
  background-color: rgba(0,0,0,.1);
  padding: 10px;
  border-radius: .5em;
  border: 1px solid rgba(0,0,0,.2);
  margin: 0 0 2em 0

.controls select {
  font-size: .9em;

#container {
  writing-mode: horizontal-tb;
  display: flex;
  justify-content: center;

.box {
  border: 5px solid rgb(108,91,123);
  border-radius: 5px;
  padding: 10px;
  margin: 10px;
  height: 200px;
  width: 200px;

.floated {
  width: 40px;
  height: 40px;
  background-color: rebeccapurple;

.logical .floated {
  float: inline-start;
  margin-inline-end: 20px;
  margin-block-end: 20px;

.physical .floated {
  float: left;
  margin-right: 20px;
  margin-bottom: 20px;
var writingMode = document.getElementById("writingMode");
writingMode.addEventListener("change", function (evt) {
  document.getElementById("container").style.writingMode = evt.target.value;

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.