HTML Style Guide
In this page:
lowercase का महत्व
हालांकि HTML case-insensitive है, tags और attributes को lowercase में लिखना industry standard है। इसे W3C द्वारा recommend किया जाता है और XHTML जैसे strict formats में यह जरूरी भी है।
उदाहरण: The Importance of lowercase
<p>Correct: lowercase tag names</p>
<P>Incorrect: uppercase tag names</P>
Attribute Quotes को Standardize करना
HTML आपको attribute values के चारों ओर quotes छोड़ने की अनुमति देता है, अगर उनमें spaces न हों। हालांकि, quotes छोड़ना एक बुरी आदत है जो values में spaces या special characters होने पर layout-breaking errors पैदा कर सकती है।
उदाहरण: Standardizing Attribute Quotes
<!-- Correct: quotes protect values with spaces -->
<img src="my photo.jpg" alt="My photo">
<!-- Bad: omitting quotes breaks multi-word values -->
<img src=my photo.jpg alt=My photo>
Consistent Indentation और Nesting
Indentation इस बात पर असर नहीं डालता कि browser आपके page को कैसे render करता है, लेकिन readability के लिए यह बेहद जरूरी है। nested child elements को 2 या 4 spaces से indent करने से आपका page structure एक नज़र में पढ़ना आसान हो जाता है।
उदाहरण: Consistent Indentation and Nesting
<div>
<p>Indented by 2 spaces</p>
</div>
Self-Closing Elements को Close करना
आधुनिक HTML5 में, self-closing elements (जैसे img या br) में trailing slash जोड़ना optional है। हालांकि, एक style चुनकर पूरे प्रोजेक्ट में उसे लगातार इस्तेमाल करना साफ कोड के लिए जरूरी है।
उदाहरण: Closing Self-Closing Elements
<br>
<br />
Files और Folders का Naming
Web servers case-sensitive होते हैं। अपनी site publish करते समय टूटे हुए links से बचने के लिए, आपको अपनी files और folders को हमेशा lowercase में नाम देना चाहिए, और शब्दों को अलग करने के लिए spaces की जगह hyphens इस्तेमाल करना चाहिए।
उदाहरण: Naming Files and Folders
<link rel="stylesheet" href="css/main-styles.css">
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: