How can I insert an image into a div?

I currently have a div from my html file that has styling from my css file as well. When I try to append a .jpg picture from my .js file to the div, it doesn’t utilize the already defined styling. Am I appending the picture incorrectly? I don’t quite understand why it’s not using the defined styling.

var img = new Image();

img[0] = new Image();
img[0].src = '1.jpg';
img[1] = new Image();
img[1].src = '2.jpg';

document.getElementById('picture').append(img[0]);
#picture {
  height: 100px;
  width: 10px;
  border: 1px solid black;
}
<div id="picture">

</div>

68 thoughts on “How can I insert an image into a div?”

Leave a Comment