Web Development Guide

Learn to build websites with HTML & CSS

Welcome to Web Development

This guide will teach you the fundamentals of creating websites using HTML and CSS. Whether you're a complete beginner or looking to refresh your skills, you'll find practical examples and clear explanations.

HTML (HyperText Markup Language)

The structure and content of web pages. HTML uses tags to define elements like headings, paragraphs, images, and links.

CSS (Cascading Style Sheets)

The styling and layout of web pages. CSS controls colors, fonts, spacing, positioning, and visual effects.

Responsive Design

Creating websites that work well on all devices, from phones to desktop computers, using flexible layouts and media queries.

Getting Started: You only need a text editor and a web browser to start building websites. Popular editors include VS Code, Sublime Text, or even Notepad++.

HTML Basics

HTML is the foundation of every website. It provides structure and meaning to content using elements wrapped in tags.

Basic HTML Structure

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First Website</title> </head> <body> <h1>Welcome to My Website</h1> <p>This is a paragraph of text.</p> </body> </html>

Essential HTML Elements

Headings

<h1>Main Title</h1> <h2>Section Title</h2> <h3>Subsection</h3>

Text Elements

<p>Paragraph text</p> <strong>Bold text</strong> <em>Italic text</em>

Links & Images

<a href="https://example.com">Link</a> <img src="image.jpg" alt="Description">

Lists

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

Try This Example

Create a simple HTML page with a heading, paragraph, and a list of your favorite hobbies.

Remember: Every HTML tag that opens must close. Use proper nesting and indentation to keep your code readable.

CSS Basics

CSS brings your HTML to life with colors, fonts, spacing, and layout. It separates presentation from content.

Adding CSS to HTML

Inline CSS

<p style="color: blue; font-size: 18px;">Blue text</p>

Internal CSS

<head> <style> p { color: blue; font-size: 18px; } </style> </head>

External CSS

<head> <link rel="stylesheet" href="styles.css"> </head>

CSS Selectors

/* Element selector */ h1 { color: red; } /* Class selector */ .highlight { background-color: yellow; } /* ID selector */ #header { font-size: 24px; } /* Descendant selector */ nav ul li { display: inline; }

Common CSS Properties

Colors & Fonts

color: #333; background-color: #f0f0f0; font-family: Arial, sans-serif; font-size: 16px; font-weight: bold;

Spacing

margin: 20px; padding: 10px; border: 1px solid #ccc; border-radius: 5px;

Layout

display: block; width: 100%; height: 300px; text-align: center; float: left;
Pro Tip: Use external CSS files for better organization and reusability across multiple pages.

CSS Layout

Modern CSS provides powerful tools for creating flexible, responsive layouts.

Flexbox Layout

Flexbox is perfect for one-dimensional layouts (rows or columns).

.container { display: flex; justify-content: space-between; align-items: center; gap: 20px; } .item { flex: 1; /* Equal width items */ }

Grid Layout

CSS Grid is ideal for two-dimensional layouts.

.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 20px; } .grid-item { background: #f0f0f0; padding: 20px; }

Box Model

Understanding the box model is crucial for layout control.

.box { width: 200px; /* Content width */ height: 100px; /* Content height */ padding: 20px; /* Space inside the border */ border: 2px solid #333; /* Border thickness */ margin: 10px; /* Space outside the border */ box-sizing: border-box; /* Include padding and border in width */ }

Layout Example

<div class="navbar"> <div class="logo">Logo</div> <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> </div>
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem; background: #333; color: white; } .navbar nav a { color: white; text-decoration: none; margin-left: 1rem; }
Layout Tip: Use Flexbox for navigation bars and button groups. Use Grid for complex page layouts and card arrangements.

Responsive Design

Responsive design ensures your website looks great on all devices.

Viewport Meta Tag

Always include this in your HTML head:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Media Queries

Media queries apply different styles based on screen size:

/* Mobile styles (default) */ .container { padding: 10px; } /* Tablet styles */ @media (min-width: 768px) { .container { padding: 20px; } } /* Desktop styles */ @media (min-width: 1024px) { .container { padding: 40px; max-width: 1200px; margin: 0 auto; } }

Responsive Images

img { max-width: 100%; height: auto; }

Flexible Grid

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }

Responsive Navigation

.nav-menu { display: flex; flex-direction: column; } @media (min-width: 768px) { .nav-menu { flex-direction: row; gap: 2rem; } }
Mobile First: Start with mobile styles and add larger screen styles with media queries. This approach is more efficient and ensures good mobile performance.

Practice Projects

Put your skills to the test with these progressive projects.

🚀 Build Real Websites

Start with simple projects and gradually increase complexity

Project Ideas

  1. Personal Portfolio

    Create a simple page about yourself with sections for bio, skills, and contact information. Practice HTML structure and basic CSS styling.

  2. Recipe Website

    Build a multi-page site with a recipe collection. Include ingredients lists, instructions, and images. Practice navigation and CSS Grid.

  3. Business Landing Page

    Create a professional landing page with hero section, services, testimonials, and contact form. Focus on responsive design and visual hierarchy.

  4. Photo Gallery

    Build an image gallery with categories and filters. Practice CSS Grid, Flexbox, and responsive images.

  5. Blog Template

    Design a blog layout with header, sidebar, main content area, and footer. Practice complex layouts and typography.

Development Workflow

1. Plan

Sketch your design on paper or use design tools. Plan your HTML structure and identify reusable components.

2. Structure

Write your HTML first. Focus on semantic markup and proper document structure before adding any styling.

3. Style

Add CSS progressively. Start with basic styles, then layout, then decorative elements and responsive features.

4. Test

Test your site on different devices and browsers. Validate your HTML and CSS code.

Keep Learning: Web development is constantly evolving. Follow web development blogs, join communities, and practice regularly to improve your skills.

Quick Start Template

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Your Project Name</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; line-height: 1.6; } .container { max-width: 1200px; margin: 0 auto; padding: 20px; } </style> </head> <body> <div class="container"> <h1>Your Content Here</h1> </div> </body> </html>