title: Append child <img> to <a> in JavaScript
body: <p>Here is my code:</p>
  <pre><code>let a = document.createElement('a');
  a.role = &quot;menuitem&quot;;
  a.tabindex = &quot;-1&quot;;
  a.href = &quot;#&quot;;
  a.onclick = function() {reloadPageWithChanges()};
  a.innerHTML = stories[&quot;Chapter1&quot;];
  let img = document.createElement('img');
  img.src = `pictures/cars/car1.png`;
  img.style.marginRight = &quot;3px&quot;;
  img.style.marginLeft = &quot;3px&quot;;
  a.appendChild(img);
  body.appendChild(a);
  </code></pre>
  <p>What this code does is that it creates a link that <code>onclick</code> reloads the page (with some small changes in the UI). This link contains the name (<code>stories[&quot;Chapter1&quot;]</code>) and a picture next to it. However, this picture is always positioned on the right side from the text. I want it to be placed on the left side, so that all of these links (if there is more of them) have pictures left aligned. Is there any way to do that, using JavaScript's DOM?</p>