HTML Folder Structure

HTML Folder Structure defines how files and folders are organized in a web project. A clean structure separates HTML, CSS, JavaScript, images, and assets, making the project easy to manage, scalable, and maintainable. It is essential for professional web development.

8 views
5 min read
Try It Yourself

Experiment with the code in an interactive editor

HTML Best Practices

1<!-- ✅ Always use lowercase tags -->
2<p>Good</p>
3<!-- ❌ <P>Bad</P> -->
4
5<!-- ✅ Always close tags -->
6<li>Item</li>
7<!-- ❌ <li>Item -->
8
9<!-- ✅ Always use alt in images -->
10<img src="img.jpg" alt="Description">
11<!-- ❌ <img src="img.jpg"> -->
12
13<!-- ✅ Use semantic tags -->
14<header>, <main>, <footer>
15<!-- ❌ <div class="header"> -->
16
17<!-- ✅ Use external CSS -->
18<link rel="stylesheet" href="style.css">
19<!-- ❌ Inline CSS -->
20
21<!-- ✅ Only ONE H1 per page -->
22<h1>Main Title</h1>
23<h2>Subtitle</h2>
24<!-- ❌ Multiple H1 tags -->
25
26<!-- ✅ Always add viewport meta tag -->
27-< meta name="viewport" content="width=device-width, initial-scale=1.0">
28
29<!-- ✅ Always add charset UTF-8 -->
30-< meta charset="UTF-8">
31
32<!-- ✅ Use rel="noopener noreferrer" with target="_blank" -->
33<a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a>

Folder Structure:

1project/
23├── index.html          # Home page
4├── about.html          # About page
5├── contact.html        # Contact page
67├── css/
8│   └── style.css       # All CSS styles
910├── js/
11│   └── script.js       # All JavaScript
1213├── images/
14│   ├── logo.png        # Company logo
15│   ├── banner.jpg      # Hero banner
16│   └── icons/          # Icon folder
17│       ├── home.svg
18│       └── user.svg
1920└── fonts/              # Custom fonts (if any)
21    └── custom-font.woff2
1<!-- In index.html (same folder) -->
2<link rel="stylesheet" href="css/style.css">
3<script src="js/script.js"></script>
4<img src="images/logo.png" alt="Logo">
5
6<!-- In about.html (same folder) -->
7<link rel="stylesheet" href="css/style.css">
8<script src="js/script.js"></script>
9<img src="images/logo.png" alt="Logo">
10
11<!-- Linking between pages -->
12<a href="index.html">Home</a>
13<a href="about.html">About</a>
14<a href="contact.html">Contact</a>

Practice Exercises

Exercise 1: Create Your First Page

Create a webpage with:

  • A main heading (your name)

  • A paragraph about yourself

  • An image (any image)

  • A link to Google that opens in new tab

Exercise 2: Create a Form

Create a contact form with:

  • Name field (required)

  • Email field (required, email type)

  • Message field (textarea)

  • Submit button

Exercise 3: Create a Semantic Layout

Create a webpage with:

  • <header> with navigation

  • <main> with an <article>

  • <aside> with related links

  • <footer> with copyright

Exercise 4: Create a Responsive Image

Create a webpage with:

  • An image that changes based on screen size

  • Use <picture> tag or srcset

Exercise 5: Create a Complete Portfolio

Create a portfolio page with:

  • Semantic HTML structure

  • Profile image with alt text

  • Skills list

  • Contact form with validation

  • SEO meta tags

  • Proper folder structure