Style Guide for HTML

Style Guide for HTML developers ko clean, consistent aur readable HTML code likhne me help karta hai. Ek proper Style Guide for HTML follow karne se code ko samajhna aur maintain karna easy ho jata hai.


Important Points in Style Guide for HTML

Neeche diye gaye rules Style Guide for HTML ke important best practices hain jo developers ko clean aur organized HTML code likhne me help karte hain.

1. DOCTYPE Declaration

Hamesha document ki first line me <!DOCTYPE html> declare karo.

Example:

DOCTYPE Declaration

Yeh browser ko batata hai ki document HTML5 format me likha gaya hai.


2. Lowercase Element Names

HTML element names hamesha lowercase me likho.

Correct:

<p> This is a paragraph </p>

Incorrect:

<P> This is a paragraph </P>

3. Lowercase Attribute Names

Attribute names bhi lowercase me hone chahiye.

Example:

Lowercase Attribute Names

4. Close All HTML Elements

Sabhi HTML elements ko properly close karna chahiye.

Example:

<p>This is a paragraph</p>

5. Attribute Values in Quotes

Attribute values ko hamesha double quotes (” “) me likhna chahiye.

Example:

Attribute Values in Quotes

6. Image Attributes

Images me alt, width aur height attributes specify karna best practice hai.

Example:

Image Attributes

7. Avoid Unnecessary Spaces

Equal sign (=) ke around extra spaces avoid karo.

Correct:
<img src=image.jpg>
Incorrect:
<img src = image.jpg>

8. Avoid Very Long Code Lines

Bahut lambi code lines avoid karo taaki code readable rahe.


9. Use Blank Lines

Logical blocks ke beech blank line dene se code readable ho jata hai.

Example:
<header>
<h1>My Website</h1>
</header><section>
<p>Welcome to my website.</p>
</section>


10. Use Proper Indentation

Indentation ke liye 2 spaces use karo aur tab key avoid karo.

Example:

<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>

11. Always Include <title>

<title> element kabhi skip mat karo. Yeh SEO aur browser tab title ke liye important hota hai.

Example:

<title>My Website</title>

12. Include Basic Structure

Har HTML document me <html>, <head> aur <body> tags include hone chahiye.

Example:

<html>
<head>
<title>Example</title>
</head>
<body>
Content here
</body>
</html>

13. Empty Elements

Empty elements ko close karna optional hai.

Example:

Empty Elements

ya

Empty Elements

Bas same style consistently use karo.


14. Add Language Attribute

<html> tag me lang attribute add karna chahiye.

Example:

<html lang=“en”>

15. Character Encoding

Document ke start me character encoding define karo.

Example:

Empty Elements

16. Viewport for Responsive Design

Responsive design ke liye viewport meta tag add karo.

Example:

Viewport for Responsive Design

17. Comments

  • Short comments ek line me likho

  • Long comments properly format aur indent karo

Example:

Comments

18. Linking CSS

CSS file ko simple syntax se link karo.

Example:

Linking CSS

19. Writing CSS Rules

Short CSS rules ek line me likh sakte ho, lekin long rules multi-line me likho.

Example:

Writing CSS Rules

Opening bracket same line me rakho aur har property ke baad semicolon lagao.


20. Loading JavaScript

JavaScript file ko simple syntax se load karo.

Example:

Loading JavaScript

JavaScript me IDs case-sensitive hote hain, isliye naming consistent rakho.


21. File Naming

  • File names hamesha lowercase me rakho

  • HTML files .html ya .htm extension use karti hain

  • CSS files .css extension use karti hain

  • JavaScript files .js extension use karti hain

.html aur .htm me koi functional difference nahi hota.


22. Default File

Agar URL me filename specify nahi hota, to server default file load karta hai jaise:

  • index.html

  • default.html


Is tarah Style Guide for HTML follow karne se code clean, readable aur maintainable ban jata hai. Har developer ko better web development ke liye Style Guide for HTML practices follow karni chahiye.

Leave a Comment