<div><p>lr</p></div>
<div><p>lr-tb</p></div>
<div><p>rl</p></div>
<div><p>rl-tb</p></div>
<div><p>tb</p></div>
<div><p>tb-rl</p></div>
div {
  display: inline-block;
  width: 200px;
  height: 200px;
  border: 1px solid black;
  margin: 4px;
}

p {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}
const divs = document.getElementsByTagName("div")

for (let elem of divs) {
  const style = elem.children[0].innerHTML
  elem.children[0].style.writingMode = style
  elem.children[0].innerHTML = style + "<br />" + style
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.