HTML TOPICS
- ELEMENTS
- ATTRIBUTES
- FORMATING
- IMAGE
- TABLES
- LISTS
- COLORS
- COMMENTS
HTML IMAGES
The HTML <img>
tag is used to embed an image in a web page.
The <img>
tag is empty, it contains attributes only, and does not have a closing tag.
The <img>
tag has two required attributes:
- src – Specifies the path to the image
- alt – Specifies an alternate text for the image
Syntax
<img src=”url“ alt=”alternatetext“>
<!DOCTYPE html>
<html>
<head>
<title>WebPage</title>
</head>
<body>
<h1>IMAGE</h1>
<img src=”lotus.jpg” alt=”lotus image”/>
</body>
</html>
Output

Height and width attribute with img tag
It is an optional attribute which is used to specify the width and height to display the image
<!DOCTYPE html>
<html>
<head>
<title>WebPage</title>
</head>
<body>
<h1>IMAGE</h1>
<img src=”lotus.jpg” alt=”lotus image” height=”300px” width=”600px”/>
</body>
</html>
Output

IMAGE ATTRIBUTES <img/> | USE | EXAMPLE |
---|---|---|
Src | Image url | <img src="image.png" alt="Test Image"/> |
Width,Height | Set image width and height in pixels | <img src="image.png" width="100" height="100"/> |
Border | Set image border.0 means No border. | <img src="image.png" border="2"/> |
Align | Image Alignment-Left,Center or Right. | <img src="image.png align="right"/> |