-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics
<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.
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics