Coding with Sanjay Official

🎯 Welcome to Coding With Sanjay Official – CODING Seekhne Ki Pehli Seedhi Yahin Se Shuru Karein πŸ’»

Frontend & Functionality

Java Script

Coming SoonπŸ”’

Type Script

Coming SoonπŸ”’

Tuesday, September 8, 2026

HTML <picture> Element in Hinglish – Complete Guide (2026)

Introduction

HTML me normally images ko webpage par display karne ke liye <img> tag ka use kiya jata hai. Lekin modern websites ko different screen sizes, devices, resolutions aur image formats ke liye optimize karna zaruri hota hai.

Agar hum har device par ek hi large image load karte hain, to mobile users ke liye unnecessary data download ho sakta hai aur webpage ki loading speed affect ho sakti hai. Isi problem ko solve karne ke liye HTML me <picture> element ka use kiya jata hai.

HTML <picture> element browser ko ek hi image ke multiple possible sources provide karne ki facility deta hai. Browser available conditions ke according suitable source choose karta hai.

Iska use especially responsive images, different image formats, mobile aur desktop ke liye different images aur modern website performance optimization me kiya jata hai.

Is complete guide me hum HTML <picture> element ko Beginner se Advanced level tak Hinglish me step by step samjhenge. Is article me syntax, <source> tag, srcset, media, type, fallback image, responsive images, WebP, practical examples aur common mistakes bhi cover ki jayengi.


πŸ“š Is Article Me Aap Kya Seekhenge?

  • HTML <picture> Element Kya Hai?
  • <picture> Element ki zarurat kyon hoti hai?
  • <picture> aur <img> me difference
  • <source> Tag kya hai?
  • srcset Attribute kya hai?
  • media Attribute ka use
  • type Attribute ka use
  • Responsive Images kaise banaye?
  • Mobile aur Desktop ke liye different images
  • WebP, PNG aur JPG formats ka use
  • Fallback Image kya hoti hai?
  • Multiple <source> tags ka use
  • Practical HTML <picture> Examples
  • Common Mistakes
  • SEO aur Image Performance Tips
  • Frequently Asked Questions
  • HTML <picture> Element ka Summary

What Is the HTML <picture> Element?

HTML <picture> element ek container element hai jiska use ek image ke liye multiple image sources provide karne ke liye kiya jata hai. Browser available <source> elements ko evaluate karta hai aur jo source current conditions ke according suitable hota hai, usko use karta hai.

Iska sabse important benefit ye hai ki developer ek hi image ke different versions provide kar sakta hai. For example, mobile users ke liye ek portrait image aur desktop users ke liye ek wide landscape image provide ki ja sakti hai.

HTML picture element responsive images example showing desktop landscape and mobile portrait image
HTML <picture> element browser ko device ke hisaab se sahi image choose karne me help karta hai - Desktop par landscape aur Mobile par portrait image.

Isi tarah ek website WebP jaise modern format ko prefer kar sakti hai aur JPG ko fallback ke roop me rakh sakti hai.

Basic Example

<picture>
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Sample Image">
</picture>

Is example me browser pehle WebP source ko consider karega. Agar WebP source use nahi ho pata, to <img> element me di gayi JPG image fallback ke roop me available rahegi.

πŸ’‘ Important: <picture> ke andar <img> element rakhna zaruri hai. Ye fallback image ke saath accessibility ke liye bhi important hai.

Why Is the HTML <picture> Element Used?

Modern websites different devices par open hoti hain. Mobile phone, tablet, laptop aur desktop ki screen width aur resolution alag-alag ho sakti hai. Ek single image ko har situation me use karna hamesha efficient nahi hota.

HTML <picture> element developer ko image selection par better control deta hai. Iski madad se different conditions ke liye different image sources provide kiye ja sakte hain.

Main Uses of the <picture> Element

  • Mobile aur desktop ke liye different images show karna.
  • Responsive images create karna.
  • WebP jaise modern image formats provide karna.
  • JPG aur PNG ko fallback ke roop me rakhna.
  • Art direction ke liye different image composition use karna.
  • Different screen sizes ke liye suitable image source provide karna.
  • Website performance ko improve karne me help karna.
  • Better user experience provide karna.

Example: Mobile aur Desktop Image

<picture>
  <source media="(max-width: 600px)" srcset="mobile.jpg">
  <img src="desktop.jpg" alt="Responsive Website Banner">
</picture>

Is example me mobile screen ke liye mobile.jpg source provide kiya gaya hai aur img element me desktop image fallback ke roop me rakhi gayi hai.


HTML <picture> vs <img>

Beginners ke liye ye samajhna important hai ki <img> aur <picture> dono images display karne se related hain, lekin unka purpose same nahi hai.

<img> Tag

Agar aapko simply ek image webpage par display karni hai, to <img> tag sufficient hota hai.

<img src="photo.jpg" alt="My Photo">

<picture> Element

Agar aapko conditions ke according different image sources provide karne hain, to <picture> element useful hota hai.

<picture>
  <source media="(max-width: 600px)" srcset="mobile.jpg">
  <img src="desktop.jpg" alt="Website Banner">
</picture>

Simple words me, <img> ek image ko display karne ke liye use hota hai, jabki <picture> multiple possible image sources ko handle karne ke liye use kiya ja sakta hai.


HTML <picture> Element Ka Syntax

HTML <picture> ka basic structure bahut simple hota hai. Iske andar ek ya multiple <source> elements aur last me ek <img> element rakha jata hai.

<picture>
  <source srcset="image.webp" type="image/webp">
  <source srcset="image.png" type="image/png">
  <img src="image.jpg" alt="Sample Image">
</picture>

Syntax Explanation

  • <picture> → Multiple image sources ko group karta hai.
  • <source> → Browser ko alternative image source provide karta hai.
  • srcset → Image source ka URL/path provide karta hai.
  • media → Media condition specify karta hai, jaise screen width.
  • type → Image MIME type batata hai, jaise image/webp.
  • <img> → Fallback image aur final image element hota hai.

HTML <source> Tag Kya Hai?

<source> element ka use <picture> ke andar alternative image sources provide karne ke liye hota hai.

Ek <picture> ke andar multiple <source> elements ho sakte hain. Har source ke saath different condition ya image format diya ja sakta hai.

Example

<picture>
  <source srcset="image.webp" type="image/webp">
  <source srcset="image.png" type="image/png">
  <img src="image.jpg" alt="Sample Image">
</picture>

Browser available sources ko evaluate karta hai. Jo source current conditions ke according applicable hota hai, browser us source ko use kar sakta hai. Agar koi source applicable nahi hota, to <img> element fallback ke roop me use hota hai.

⚠️ Note: <source> ko generally direct webpage content ke roop me use nahi kiya jata. Ye <picture>, <audio> aur <video> jaise elements ke context me use hota hai.

What Is the srcset Attribute?

srcset attribute browser ko image source ka path provide karta hai. <picture> element ke context me ye <source> ke image URL ko specify karne ke liye commonly use hota hai.

Basic Example

<picture>
  <source srcset="banner.webp" type="image/webp">
  <img src="banner.jpg" alt="Website Banner">
</picture>

Yahan srcset browser ko banner.webp source ke baare me batata hai.

Multiple Resolution Sources

Responsive image workflows me srcset ko different image resolutions ke saath bhi use kiya ja sakta hai.

<picture>
  <source
    media="(max-width: 600px)"
    srcset="small.jpg"
  >

  <source
    media="(max-width: 1200px)"
    srcset="medium.jpg"
  >

  <img
    src="large.jpg"
    alt="Responsive Image"
  >
</picture>

Is example me screen conditions ke according different image files available karayi gayi hain.


Using the media Attribute

media attribute ka use image source ke liye media condition specify karne ke liye hota hai. Iska common use responsive design me different screen widths ke according images provide karna hai.

Mobile Image Example

<picture>
  <source
    media="(max-width: 600px)"
    srcset="mobile.jpg"
  >

  <img
    src="desktop.jpg"
    alt="Responsive Banner"
  >
</picture>

Agar current viewport ki width 600px ya usse kam condition ko satisfy karti hai, to mobile source applicable ho sakta hai.

Mobile, Tablet Aur Desktop Example

<picture>

  <source
    media="(max-width: 600px)"
    srcset="mobile.jpg"
  >

  <source
    media="(max-width: 1024px)"
    srcset="tablet.jpg"
  >

  <img
    src="desktop.jpg"
    alt="Responsive Website Image"
  >

</picture>

Is structure me mobile aur tablet ke liye specific sources diye gaye hain, jabki <img> element final fallback image provide karta hai.


Using Different Image Formats

Modern websites me WebP jaise image formats ka use common hai. HTML <picture> element ki madad se aap different formats ke sources provide kar sakte hain.

WebP With JPG Fallback

<picture>
  <source
    srcset="image.webp"
    type="image/webp"
  >

  <img
    src="image.jpg"
    alt="Beautiful Landscape"
  >
</picture>

Is structure me WebP source available hai aur JPG image fallback ke roop me di gayi hai.

WebP, PNG Aur JPG Example

<picture>

  <source
    srcset="image.webp"
    type="image/webp"
  >

  <source
    srcset="image.png"
    type="image/png"
  >

  <img
    src="image.jpg"
    alt="Sample Image"
  >

</picture>

Is example me multiple image formats available karaye gaye hain. Browser supported/applicable source ko evaluate karta hai aur fallback ke liye <img> element available rehta hai.


Responsive Images Using <picture>

Responsive image ka matlab hai ki image ko different screen sizes aur layouts ke liye appropriate source provide kiya ja sake.

For example, desktop par ek wide banner aur mobile par ek vertically optimized image zyada useful ho sakti hai.

Responsive Banner Example

<picture>

  <source
    media="(max-width: 600px)"
    srcset="banner-mobile.jpg"
  >

  <source
    media="(max-width: 1024px)"
    srcset="banner-tablet.jpg"
  >

  <img
    src="banner-desktop.jpg"
    alt="Responsive Website Banner"
  >

</picture>

Is technique ko websites, landing pages, blogs, e-commerce pages aur responsive web designs me use kiya ja sakta hai.


Art Direction Kya Hai?

Responsive images ka ek advanced use art direction hai. Isme sirf image ka size change nahi kiya jata, balki different screen sizes ke liye image ka composition bhi change kiya ja sakta hai.

For example, desktop par ek wide landscape photograph aur mobile par same subject ka cropped portrait version display kiya ja sakta hai.

Art Direction Example

<picture>

  <source
    media="(max-width: 600px)"
    srcset="product-mobile.jpg"
  >

  <img
    src="product-desktop.jpg"
    alt="Featured Product"
  >

</picture>

Is approach ka advantage ye hai ki mobile screen par image ka important subject better visible reh sakta hai.


Complete Responsive Image Example

Ab ek complete example dekhte hain jisme screen size aur image format dono ka concept use kiya gaya hai.

<picture>

  <source
    media="(max-width: 600px)"
    srcset="mobile.webp"
    type="image/webp"
  >

  <source
    media="(max-width: 1024px)"
    srcset="tablet.webp"
    type="image/webp"
  >

  <source
    srcset="desktop.webp"
    type="image/webp"
  >

  <img
    src="desktop.jpg"
    alt="Responsive Website Banner"
  >

</picture>

Is example me mobile, tablet aur desktop ke liye different sources diye gaye hain. WebP sources preferred hain aur JPG image <img> ke through fallback ke roop me available hai.


How Does the Browser Select an Image?

HTML <picture> ko samajhne ke liye browser ke source selection process ko samajhna important hai.

  1. Browser <picture> ke andar available sources ko dekhta hai.
  2. Applicable media condition ko evaluate kiya jata hai.
  3. Agar type diya gaya hai to browser format support ko consider karta hai.
  4. Applicable source milne par browser us source ko use kar sakta hai.
  5. Agar koi source applicable nahi hota, to <img> fallback available rehta hai.
πŸ’‘ Important: <picture> ka source selection CSS ki tarah sirf visual hiding nahi hai. Iska purpose browser ko appropriate image resource select karne ke options dena hai.

Common Mistakes While Using <picture>

1. <img> Tag Na Likhna

<picture> ke andar <img> element ko zarur rakhna chahiye.

❌ Wrong:

<picture>
  <source srcset="image.webp" type="image/webp">
</picture>

✅ Correct:

<picture>
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Sample Image">
</picture>

2. Wrong Image Path

Agar srcset me image ka path galat diya gaya hai, to browser image load nahi kar payega.

❌ Wrong:

<source srcset="images/banner.webp">

Agar actual image kisi different folder me hai, to correct path use karna zaruri hai.


3. Wrong MIME Type

type attribute me correct MIME type specify karna chahiye.

❌ Wrong:

<source
  srcset="image.webp"
  type="image/jpg"
>

✅ Correct:

<source
  srcset="image.webp"
  type="image/webp"
>

JPG image ke liye commonly image/jpeg MIME type use kiya jata hai.


4. alt Attribute Ignore Karna

<img> element me meaningful alt text dena important hai. Ye accessibility aur image context ke liye useful hota hai.

❌ Avoid:

<img src="banner.jpg">

✅ Better:

<img
  src="banner.jpg"
  alt="Responsive coding website banner"
>

5. Source Order Ko Carefully Na Rakhna

Jab multiple conditions applicable ho sakti hain, to <source> elements ka order important ho sakta hai. Isliye conditions ko logical order me rakhna chahiye aur overlapping media conditions ko avoid karna chahiye.


SEO Tips for Images in HTML

HTML <picture> element directly search engine ranking ki guarantee nahi deta, lekin properly optimized images website performance, accessibility aur user experience ko improve karne me help kar sakti hain.

1. Meaningful Alt Text Use Karein

<img
  src="coding-course.jpg"
  alt="HTML CSS JavaScript coding course"
>

2. Descriptive File Names Use Karein

image123.jpg ke badle descriptive filename use karna better hai.

html-picture-element-guide.jpg

3. Image Size Optimize Karein

Bahut large image files website loading ko slow kar sakti hain. Isliye appropriate dimensions aur compressed image files use karna useful hai.

4. Modern Image Formats Consider Karein

WebP jaise modern image formats ko suitable situations me use kiya ja sakta hai, saath me appropriate fallback bhi provide kiya ja sakta hai.

5. Lazy Loading Consider Karein

Agar image page ke initial viewport ke bahar hai, to loading="lazy" useful ho sakta hai.

<picture>
  <source srcset="article-image.webp" type="image/webp">

  <img
    src="article-image.jpg"
    alt="HTML picture element example"
    loading="lazy"
  >
</picture>
πŸ’‘ SEO Tip: Alt text me unnecessary keywords bharne ke bajay image ko accurately describe karein. Natural aur useful alt text accessibility ke liye bhi better hota hai.

Advanced Example: Responsive Image With WebP

Ab ek practical advanced example dekhte hain jisme mobile aur desktop conditions ke saath WebP format ka use kiya gaya hai.

<picture>

  <source
    media="(max-width: 600px)"
    srcset="coding-mobile.webp"
    type="image/webp"
  >

  <source
    srcset="coding-desktop.webp"
    type="image/webp"
  >

  <img
    src="coding-desktop.jpg"
    alt="Modern coding workspace"
    loading="lazy"
  >

</picture>

Is example me mobile users ke liye mobile WebP image aur larger screens ke liye desktop WebP image available hai. JPG image fallback ke roop me rakhi gayi hai.


Practical Example: Website Hero Section

Real-world websites me <picture> element ka use hero banner ya promotional section me bhi kiya ja sakta hai.

<section class="hero">

  <picture>

    <source
      media="(max-width: 600px)"
      srcset="hero-mobile.webp"
      type="image/webp"
    >

    <source
      srcset="hero-desktop.webp"
      type="image/webp"
    >

    <img
      src="hero-desktop.jpg"
      alt="Modern web development workspace"
    >

  </picture>

</section>

Is structure ko website landing pages, portfolio websites, coding websites, blogs aur business websites me use kiya ja sakta hai.


When Should You Use <picture>?

Har image ke liye <picture> use karna zaruri nahi hai. Agar aapko simple image display karni hai, to normal <img> element ka use karna enough ho sakta hai.

Lekin in situations me <picture> useful ho sakta hai:

  • Jab mobile aur desktop ke liye different image composition chahiye.
  • Jab multiple image formats provide karne hon.
  • Jab art direction ki zarurat ho.
  • Jab specific viewport conditions ke liye image source change karna ho.
  • Jab modern image format ke saath fallback provide karna ho.

HTML <picture> Element Ke Advantages

  • Responsive image sources provide kar sakte hain.
  • Different image formats provide kar sakte hain.
  • Mobile aur desktop ke liye different images use kar sakte hain.
  • Art direction implement kar sakte hain.
  • Fallback image provide kar sakte hain.
  • Modern responsive websites me useful hai.
  • Image resource selection par better control deta hai.

HTML <picture> Element Ki Limitations

<picture> powerful hai, lekin iska use har image problem ka solution nahi hai.

  • Simple single image ke liye ye unnecessary ho sakta hai.
  • Multiple sources maintain karne se website code badh sakta hai.
  • Har source image ko properly optimize karna padta hai.
  • Overlapping media conditions ko carefully handle karna padta hai.

Isliye <picture> ka use tab karein jab multiple image sources ki actual requirement ho.


Frequently Asked Questions About HTML <picture>

1. HTML <picture> Element Kya Hai?

<picture> ek HTML element hai jo ek image ke liye multiple possible image sources provide karne ke liye use hota hai.

2. Kya <picture> Ke Andar <img> Zaruri Hai?

Haan. <img> element ko fallback aur final image element ke roop me rakhna chahiye.

3. Kya <picture> Mobile Responsive Hai?

Haan. media conditions ke saath different viewport sizes ke liye different image sources provide kiye ja sakte hain.

4. Kya <picture> Me WebP Use Kar Sakte Hain?

Haan. type="image/webp" ke saath WebP source provide kiya ja sakta hai.

5. Kya <picture> Aur CSS Same Hain?

Nahi. CSS primarily presentation aur layout control karta hai, jabki <picture> multiple image resources ke selection ke liye HTML structure provide karta hai.

6. Kya Har Image Ke Liye <picture> Use Karna Chahiye?

Nahi. Simple image ke liye normal <img> tag kaafi ho sakta hai. <picture> tab use karein jab multiple image sources, formats ya art direction ki requirement ho.


Conclusion

HTML <picture> element modern responsive web development ka ek useful feature hai. Iski madad se developers ek hi image ke multiple sources provide kar sakte hain aur browser ko current conditions ke according suitable source select karne ka option milta hai.

Is article me humne HTML <picture> element ka meaning, syntax, <source> tag, srcset, media, type, responsive images, WebP, JPG, PNG, art direction, fallback images, SEO tips aur practical examples ko detail me samjha.

Agar aap responsive website bana rahe hain aur mobile, tablet aur desktop ke liye different images ya image formats provide karna chahte hain, to <picture> element aapke liye kaafi useful ho sakta hai.


πŸ“Œ Summary

  • <picture> multiple image sources provide karta hai.
  • <source> alternative image sources provide karta hai.
  • srcset image source URL/path specify karta hai.
  • media viewport/media conditions specify kar sakta hai.
  • type image MIME type specify karta hai.
  • <img> fallback aur final image element ke roop me important hai.
  • WebP, PNG aur JPG jaise formats ke saath <picture> use kiya ja sakta hai.
  • Mobile, tablet aur desktop ke liye different image sources provide kiye ja sakte hain.
  • Art direction ke liye different image composition use ki ja sakti hai.
  • Meaningful alt text accessibility aur image context ke liye important hai.
  • Simple image ke liye normal <img> element sufficient ho sakta hai.
πŸš€ Next Article: Agle article me hum HTML Image Maps ko detail me seekhenge. Hum jaanenge ki Image Map kya hota hai, <map> aur <area> tags kaise work karte hain aur ek hi image ke different areas ko clickable kaise banaya jata hai.

πŸ™ Coding with Sanjay Official ke saath isi tarah HTML, CSS, JavaScript, PHP, Python aur Web Development step by step seekhte rahiye. Hamara maksad hai ki aap Theory se lekar Practice, MCQ Quiz aur Exam Preparation tak sab kuch ek hi jagah aasani se seekh saken.

πŸ“– Related Articles: Agar aapne abhi tak HTML Tables aur HTML Lists ke baare me nahi padha hai, to pehle in articles ko zarur padhen.

πŸ“š Helpful Links

πŸ’™ Coding with Sanjay Official – "Coding Ko Aasaan Banayein, Roz Kuch Naya Seekhein!" πŸš€

No comments:

Post a Comment