1

How does one change the size of an image in HTML? I am importing an image from online but I want it to be a different size. How can I make it be the correct size needed in my code/ website?

  • Are we talking here about display size or the image actual size? For example, if I have an image that is 1920x2400 then I have two options: 1- to put some CSS specifying the display size like width: 25% or width: 480px. 2- if we are talking about modifying the actual image and resize it to make a thumbnail for example, then that will be done on the server using e.g. PHP to generate a new image 480x600. So far I'm assuming you would like to keep the aspect ratio intact. There are a few PHP libraries that can do that like PHP's ImageMagick or GD. – Mohammed Joraid Jul 10 '18 at 03:51
  • https://stackoverflow.com/questions/14649645/resize-image-in-php – Mohammed Joraid Jul 10 '18 at 03:54

1 Answers1

0

Generally something like height and width can be used in CSS, as in:

image {
   height: 0px;
   width: 0px;
}

Or to change size in HTML itself, something like:

<img src=" " alt=" " style="width:500px;height:600px;">

I'm unsure how helpful and in-detail my answer is, but this has worked for me in the past. I hope this helps somehow.
~Shantel

Shantel Pike
  • 28
  • 2
  • 7