HTML IMAGES
Images are used to make web pages beautiful and more descriptive. More information can be presented through images and in a much easier way.
HTML displays images using <img> tag.
<img> tag is an empty tag. It does not have a closing tag.It has attributes only.
Syntax of <img> tag
<img src="image_url" alt="about image">
Syntax explanation:
- src - Used for giving url of image.
- alt - It provides additional information about the image.
<img src="flowers.jpg" alt="Beautiful flowers">
Try It
Output:
HTML img tag Attribute
<img> tag has other attributes too like width, height and border.These attributes let the user to define height,width and border of image.
-
width - It defines width of image.we can set width either in percentage,in pixels or in
other scales.
<img src="flowers.jpg" width="250px">
-
height - It defines height of image.we can set height either in percentage,in pixels or in
other scales.
<img src="flowers.jpg" height="250px">
-
border - We can also create border around the image using border attribute.
<img src="flowers.jpg" border="2">
A working example:
<img src="cat.jpg" width="250px" height="250px" border="2">
Try It
Output: