Solution 1 :

Safari has no display property defined for the <code> element. You can simply add

code { display: block; }

to your style and it should work.

I hope I did understand your question correct.

var log = document.getElementById("div-1");
var output = document.getElementById("div-2");
console.log(log);
function addTo(where) {
  let msg = document.createElement("code");
  let lb = document.createElement("br");
  msg.textContent = "n This is text.";
  where.insertBefore(lb, where.firstChild);
  where.insertBefore(msg, where.firstChild);
}

addOne.onclick = function () {
  addTo(log);
}
addTwo.onclick = function () {
  addTo(output);
}
reset.onclick = function () {
  log.innerHTML="";
  output.innerHTML="";
}
.output-div {
          display:inline-block;
          background-color: rgb(5, 20, 20);
          border: 2px solid black;
          padding-top:20px;
          overflow: auto;
          color: white;
      }
body {
  background-color: black;
}
#div-1 {
  width:71vw;
  height: 40vh;
  top:17px;
  background-color:gray;
  top:17px;
}
#div-2 {
  width:20vw;
  height: 40vh;
  top:17px;
  background-color:blue;
}

code {
  display:block;
}
<button id="addOne">Add text to div one.</button>
<button id="addTwo">Add text to div two.</button>
<button id="reset">Reset the divs.</button>
<br>
<div id="div-1" class="output-div"></div>
<div id="div-2" class="output-div"></div>

Problem :

I am currently writing a program in which I need to have two divs, which hold a log and an output. When adding elements to the log, the divs try to align in strange ways (they move up and down to try to match the other div’s text).

To fix this, I added vertical-align:top; to the divs’ class. This works great in Chrome, but not at all in Safari. Sometimes in Safari the div will just duplicate itself, which is really weird.

Here is a codepen demonstrating the issue. Any help is appreciated. Thanks!

I am using macOS 10.14.5 and Safari version 12.1.1.

By