22 Mar Inserting Image in HTML
For a web page, images are necessary and atleast one image is useful for SEO as well. To insert images in an HTML web page, use the <img> tag.
To add an image, include an img tag and set the image source i.e.
1 2 3 |
<img src="/html/images/test.png" alt="Simply Easy Learning" width="200" height="80"> |
Add images anywhere in the HTML document. Above, we used the,
- src attribute to set the image source,
- alt for alternate text,
- width for image width
- height for image height.
Note: img tag is an empty tag. Do not use a closing tag. It is not required.
With that, add the image tag inside the <body>…</body> tag always,
1 2 3 4 5 |
<body> <img src=”/wp-content/uploads/2017/11/Interview-Questions-and-Answers.png” alt="Interview QA" width="600" height="300"> </body> |
The following is an example to add image in an HTML web page,
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<!DOCTYPE html> <html> <head> <title>HTML img Example</title> </head> <body> <h1>Interview Questions</h1> <p>We provide Interview Questions as well for students, engineers and professionals. </p> <img src=”/wp-content/uploads/2017/11/Interview-Questions-and-Answers.png” alt="Interview QA" width="600" height="300"> </body> </html> |
The output:
More Examples
- Creating HTML Document
- Creating Headings in HTML web page
- Creating Paragraphs in HTML Web Page
- Page links in an HTML Web Page
- Add Title in an HTML web page
- How to create horizontal line in HTML Page
- The href attribute in HTML Page
- Image height and width attribute in HTML
- Inserting Hyperlinks on an HTML web page?
- Why head tag is used in HTML?
- How to set background color in HTML?
- How to set font color in HTML
- How to use StyleSheet in HTML
No Comments