Setting width and height of Image
The width and height attributes are used to specify the height and width of an image. The attribute values are specified in pixels by default. The width and height attributes are always declared in pixels. Please refer to the How to set the width and height of an image using HTML? article for further details.
Example: In this example we sets the width and height of an image using the <img> tag’s width and height attributes. It showcases the w3wiki logo with dimensions of 300×300 pixels.
<!DOCTYPE html>
<html>
<head>
<title>
Setting width and height of image
</title>
</head>
<body>
<p> Setting width and height of image</p>
<img src=
"https://media.w3wiki.org/wp-content/cdn-uploads/20190710102234/download3.png"
alt="w3wiki logo"
width="300"
height="300" />
</body>
</html>
Output:
HTML Images
The HTML <img> tag is used to embed an image in web pages by linking them. It creates a placeholder for the image, defined by attributes like src, width, height, and alt, and does not require a closing tag.
There are 2 ways to insert the images into a webpage:
- By providing a full path or address (URL) to access an internet file.
- By providing the file path relative to the location of the current web page file.
We will first discuss inserting the image into the webpage & simultaneously, we will understand both the above approaches.
Contact Us