-
Hajipur, Bihar, 844101
<img>
Tag?The <img>
tag is used to embed images into a webpage. It is a self-closing tag, meaning it doesn't need a closing </img>
.
<img src="image.jpg" alt="Description">
Attribute | Purpose |
---|---|
src |
Specifies the path to the image file |
alt |
Provides alternative text if the image fails |
<img src="logo.png" alt="Company Logo">
You can set size using the width
and height
attributes (in pixels):
<img src="photo.jpg" width="300" height="200" alt="A Photo">
Or use CSS:
<img src="photo.jpg" style="width:100%; height:auto;" alt="Responsive Image">
<img src="images/pic1.jpg" alt="Gallery Image">
<img src="https://example.com/banner.jpg" alt="External Image">
Wrap the image inside an <a>
tag:
<a href="https://example.com">
<img src="logo.png" alt="Go to site">
</a>
<img src="image.jpg" style="max-width:100%; height:auto;" alt="Responsive">
📝 This ensures the image scales with screen size.
<img src="book.jpg" alt="Book Cover" title="Click to view book details">
Q1. Insert an image named banner.jpg
into a webpage.
Q2. Add an alternative text “Nature Photo” to an image.
Q3. Display an image with width 500px and height 300px.
Q4. Create a responsive image using CSS.
Q5. Link an image to https://example.com
.
Q6. Load an image from an external URL.
Q7. Show an image located inside a folder named gallery
.
Q8. Use title
attribute to show a tooltip on hover.
Q9. Add multiple images in a row using HTML.
Q10. Create an image gallery layout with three images.
Q1: Which tag is used to display images in HTML?
Q2: What does the alt attribute in an image tag do?
Q3: Which attribute specifies the image path?
Q4: What is the correct syntax to add an image of dog.jpg with alternative text?
Q5: How do you make an image responsive in HTML?
Q6: Which of the following tags is self-closing?
Q7: What happens if the image file is missing?
Q8: Which attribute shows a tooltip when hovering over the image?
Q9: Which format is commonly used for web images?
Q10: How do you center an image using CSS?