I have an image, and I want the width to fill up the browser window, no matter the size of the window.
How do I do this in HTML and CSS?
One of the simplest ways to resize an image in the HTML is using the height and width attributes on the img tag. These values specify the height and width of the image element. The values are set in px i.e. CSS pixels. For example, the original image is 640×960.
You can add a div with width an height of 100%, also set image's width and height are 100%
<div id="wrapper">
<img src="https://picsum.photos/200/200">
</div>
CSS:
#wrapper, img{
width:100%;
height: 100%;
}
jsfiddle
<img src="filename.jpg" alt="alt text" width="100%" />
This assumes that the image's container is as wide as the browser window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With