HTML डॉकटाइप्स
In this page:
<!DOCTYPE html>
डॉकटाइप क्या है?
doctype declaration एक instruction है जो browser को बताता है कि किस document type और markup version की उम्मीद करनी है, जिससे यह सुनिश्चित होता है कि browser आपके page का layout consistent तरीके से render करे।
उदाहरण: What is a Doctype?
<!DOCTYPE html>
<html>
</html>
Quirks Mode बनाम Standard Mode
अगर किसी webpage पर doctype declaration missing या गलत है, तो browsers 'Quirks Mode' में स्विच हो जाते हैं।
Quirks Mode में, browsers पुराने, non-standard layout rules इस्तेमाल करके आपके pages render करते हैं ताकि बहुत पुरानी websites भी सपोर्ट हो सकें, जो आपके modern CSS styles को तोड़ देगा।
उदाहरण: Quirks Mode vs. Standard Mode
<!-- Missing doctype triggers Quirks Mode -->
<!DOCTYPE html>
<html>
</html>
आधुनिक HTML5 डॉकटाइप
पुराने HTML versions में, doctypes लंबे, complex strings होते थे जो official document type definitions (DTDs) से लिंक होते थे। HTML5 ने एक छोटी, साफ, और याद रखने में आसान declaration पेश करके इसे simplify किया।
उदाहरण: The Modern HTML5 Doctype
<!DOCTYPE html>
हिस्टोरिकल लेगेसी डॉकटाइप्स
HTML के पुराने versions (जैसे HTML 4.01 या XHTML 1.0) में आपके कोड को validate करने के लिए W3C definitions से लिंक होने वाले लंबे, complex doctype strings ज़रूरी होते थे। हालाँकि आज ये obsolete हैं, फिर भी पुरानी websites maintain करते समय इन्हें समझना उपयोगी है।
उदाहरण: Historical Legacy Doctypes
<!-- Legacy HTML 4.01 doctype -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Modern HTML5 doctype -->
<!DOCTYPE html>
वैलिडेशन और वेब स्टैंडर्ड्स
Web standards के अनुसार हर HTML page एक valid doctype से शुरू होना ज़रूरी है। अपने कोड को validate करने और W3C markup validation tests पास करने के लिए doctype शामिल करना ज़रूरी है।
उदाहरण: Validation and Web Standards
<!DOCTYPE html>
<html lang="en">
</html>
Chapter Quiz — Complete all 20 topics to unlock
0/20 topics done
Complete these topics first:
- HTML Keyboard Shortcuts
- HTML Browser Support
- HTML Character Sets
- HTML Doctypes
- HTML Audio/Video Reference
- HTML Meta Tags
- HTML ARIA Roles
- HTML Input Validation
- HTML Iframe Security
- HTML Responsive Images
- HTML Web Fonts
- HTML Icon Fonts
- HTML Progress & Meter
- HTML Output Element
- HTML Datalist
- HTML Image Maps
- HTML Browser DevTools
- HTML Validation
- HTML Quiz
- HTML Interview Prep