search

Home  >  Q&A  >  body text

I can't set the width and height of an image using unsplash

This is the html code... enter image description here

I tried changing the width multiple times...restarted VS-code multiple times and I still can't change the width. Every time the page is refreshed it gives a random size

P粉520204081P粉520204081434 days ago513

reply all(1)I'll reply

  • P粉445714413

    P粉4457144132023-09-16 18:09:17

    The link you used for the image source says it all.

    <img src="https://source.unsplash.com/random/300x300" alt=""/>
    • Containing "random" in the URL means that the image will be served randomly
    • 300x300 refers to the image width and height

    If you want images with different widths and heights, change these values ​​in the URL. For example: If you wanted an image with a width of 900 pixels and a height of 600 pixels, the url would be:

    <img src="https://source.unsplash.com/random/900x600" alt=""/>

    reply
    0
  • Cancelreply