I use the following HTML and CSS codes to make images adjust to the width of their container while automatically adjusting their height to preserve their aspect ratio.
Figure 1
To target all images automatically rather than individually coding each image you can add the following line to your stylesheet instead.
img {width: 100%; height: auto}
Figure 2
Using the





