HTML me Images ka Use
Websites me images ka use visual appeal ke liye bahut important hota hai. HTML me images display karne ke liye <img> tag ka use kiya jata hai.
<img> Tag kya hai?
<img> ek self-closing (empty) tag hota hai jo kisi image ko webpage me embed karta hai. Is tag ke do important attributes hote hain:
src: Ye image ka source ya URL specify karta hai.alt: Agar image load nahi hota toh ye alternative text dikhta hai, aur screen readers ke liye useful hota hai.
Basic Syntax:
<img src="image.jpg" alt="Image description" />
Example:
<img src="https://www.example.com/images/logo.png" alt="Company Logo" width="200" height="100" />
Is example me image ko 200px width aur 100px height me display kiya gaya hai.
Important Attributes
widthaurheight: Image ke size ko specify karte hain (pixels ya percentage me).title: Image par mouse hover karne par tooltip dikhata hai.loading: Image ke lazy loading ya normal loading ke liye use hota hai.
Image Ko Link Banana
Aap kisi image ko clickable bana kar hyperlink bhi kar sakte hain. Iske liye <img> tag ko <a> tag ke andar rakhte hain.
<a href="https://www.example.com">
<img src="logo.png" alt="Example Logo" />
</a>
Accessibility Importance
alt attribute dena zaruri hai taaki visually impaired users screen readers ka use karke samajh saken ki image me kya hai. Agar image important nahi hai toh alt="" bhi kar sakte hain.