Learn how to add an image to your webpage using HTML. This tutorial explains how to properly use the <img>
tag to display images on your site.
Step 1: Create an HTML file
Create a new file and name it image.html
.
Step 2: Add the basic HTML structure
Set up the basic structure like below.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Image Example</title> </head> <body> <!-- Content will go here --> </body> </html>
Step 3: Add an Image
Inside the <body>
tag, use the <img>
tag to add an image.
<body> <h1>My Favorite Image</h1> <img src="image.jpg" alt="A beautiful scenery" width="500"> </body>
Note: Replace image.jpg
with the actual path to your image file.
Final Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Image Example</title> </head> <body> <h1>My Favorite Image</h1> <img src="image.jpg" alt="A beautiful scenery" width="500"> </body> </html>