To resize an image in HTML, you can use the width and height attributes in the <img> tag. Here’s how you can do it:
Using width and height Attributes
<img src="image.jpg" width="300" height="200" alt="Description of image" />
width: Sets the width of the image in pixels.height: Sets the height of the image in pixels.
Using CSS for Resizing
You can also use CSS to resize images, which provides more flexibility:
<img src="image.jpg" alt="Description of image" style="width: 50%; height: auto;" />
style: Inline CSS can be used to set the width to a percentage of its container, andheight: auto;maintains the aspect ratio.
Example
<img src="image.jpg" style="width: 300px; height: auto;" alt="Description of image" />
This will resize the image to 300 pixels wide while keeping its original aspect ratio.
If you need more help or examples, feel free to ask!
