HTML Images β How to Add Images to Your Webpage (Beginnerβs Guide)
Learn how to add images in HTML using the <img> tag, set image source, alt text for SEO, size attributes, and display images properly on your website.
π What Are HTML Images?
Images make your webpage visually appealing and help convey information quickly.
In HTML, images are added using the <img> tag.
<img src="image.jpg" alt="Description of Image">
src: Specifies the path to the image file.
alt: Provides alternative text if the image cannot be displayed (important for SEO and accessibility).
π₯ Why Use Alt Text?
SEO β Search engines index your images based on alt text.
Accessibility β Screen readers can read alt text for visually impaired users.
Fallback β Displays text if the image fails to load.
<img src="faulink-logo.png" alt="Faulink Official Logo">
π Resize Images
You can control the image size using HTML attributes or CSS:
<img src="faulink-logo.png" alt="Faulink Logo" width="200" height="100">
Or with CSS:
<img src="faulink-logo.png" alt="Faulink Logo" class="logo">
<style>
.logo {
width: 200px;
height: auto;
border-radius: 8px;
}
</style>
β¨ Responsive Images
To make images responsive across devices:
<img src="faulink-logo.png" alt="Faulink Logo" style="max-width:100%; height:auto;">
This ensures the image scales based on the screen width.
π§© Linking Images
You can make an image clickable using the <a> tag:
<a href="https://www.faulink.com/">
<img src="faulink-logo.png" alt="Faulink Official Website">
</a>
Clicking the image will take the user to Faulink's website.
π§ͺ Full Example: HTML Images Page
<!DOCTYPE html>
<html>
<head>
<title>HTML Images Tutorial for Beginners</title>
</head>
<body>
<h1>HTML Images Guide</h1>
<p>Images make your website more attractive and informative.</p>
<h2>Basic Image</h2>
<img src="https://www.faulink.com/images/faulink-logo.png" alt="Faulink Logo">
<h2>Resized Image</h2>
<img src="https://www.faulink.com/images/faulink-logo.png" alt="Faulink Logo" width="200" height="100">
<h2>Responsive Image</h2>
<img src="https://www.faulink.com/images/faulink-logo.png" alt="Faulink Logo" style="max-width:100%; height:auto;">
<h2>Clickable Image</h2>
<a href="https://www.faulink.com/">
<img src="https://www.faulink.com/images/faulink-logo.png" alt="Faulink Official Website">
</a>
</body>
</html>
π Links Za Kujifunza Zaidi
π Faulink Official Website
https://www.faulink.com/
π Jifunze Web Design & Programming
https://www.faulink.com/excel_mifumo.php
π² WhatsApp kwa Msaada wa Haraka
https://wa.me/255693118509
π Unahitaji mfumo au website ya biashara?
Chagua huduma hapa chini kisha mteja bofya moja kwa moja kwenda kwenye ukurasa wa huduma au kuwasiliana nasi kwa WhatsApp.