HTML बनाम XHTML
In this page:
XHTML क्या है?
XHTML (Extensible HyperText Markup Language) एक strict, XML-based markup language है जिसे HTML की जगह लेने के लिए डिज़ाइन किया गया था। यह यह सुनिश्चित करने के लिए strict formatting rules लागू करता है कि webpages किसी भी system द्वारा साफ तरीके से parse किए जा सकें।
उदाहरण: What is XHTML?
<html xmlns="http://www.w3.org/1999/xhtml">
</html>
Strict Tag Closing Rules
Standard HTML में, कुछ elements (जैसे paragraphs) पर closing tags optional होते हैं, और self-closing tags (जैसे images) को closing slash की जरूरत नहीं होती।
XHTML में, हर एक element का एक corresponding closing tag होना चाहिए, और self-closing tags एक trailing slash के साथ खत्म होने चाहिए।
उदाहरण: Strict Tag Closing Rules
<p>HTML allows this</p>
<img src="photo.jpg" alt="Photo" />
Case Sensitivity और Lowercase Tags
Standard HTML case-insensitive है, यानी आप अपने tags uppercase या lowercase में लिख सकते हैं। XHTML पूरी तरह case-sensitive है और सभी tag और attribute names को lowercase में लिखना जरूरी है।
उदाहरण: Case Sensitivity and Lowercase Tags
<p>Correct XHTML: lowercase tags</p>
Strict Attribute Value Rules
Standard HTML में, आप disabled या readonly जैसे shorthand attributes बिना values के लिख सकते हैं, और single-word attribute values के चारों ओर quotes छोड़ सकते हैं।
XHTML attribute shorthand को मना करता है और सभी attribute values को lowercase में लिखा और double quotes में wrap किया जाना जरूरी करता है।
उदाहरण: Strict Attribute Value Rules
<input type="checkbox" disabled="disabled">
Nesting Constraints और Overlapping
HTML nesting errors के साथ काफी उदार है और overlapping tags को अपने-आप ठीक करने की कोशिश करता है। XHTML पूरी तरह structured है और सभी elements को उसी उल्टे क्रम में बंद करना जरूरी करता है जिस क्रम में वे खोले गए थे।
उदाहरण: Nesting Constraints and Overlapping
<div>
<p>Correctly nested and closed in reverse order</p>
</div>
- XHTML documents में self-closing tags पर trailing slashes शामिल करना भूल जाना।
- XHTML code के अंदर shorthand attributes इस्तेमाल करना (जैसे disabled="disabled" के बजाय disabled)।
- tags को गलत क्रम में nest करना, जिससे XML validation fail हो जाता है।
- HTML एक flexible, relaxed markup standard है, जबकि XHTML एक strict, XML-based markup standard है।
- XHTML में सभी tags lowercase में लिखे जाने, साफ तरीके से closed होने, और सही क्रमिक order में nested होने चाहिए।
- XHTML में shorthand attributes की मनाही है; सभी attributes को double quotes में wrap किए हुए complete values लिखने चाहिए।
standard web browsers flexible HTML5 और strict XHTML दोनों formats को natively support करते हैं।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: