Web Development Beginner Course
Learn how the web really works — from your first HTML page to a responsive, interactive profile site. Master HTML, CSS, JavaScript basics, and the developer tools pros use every day.
Start LearningWhat Is Web Development?
10 minWhat you'll learn
- Understand frontend vs backend
- Learn how browsers render pages
- Set up your first HTML file
Web development is how websites come to life. The frontend is everything you see (HTML, CSS, JavaScript running in your browser), while the backend handles data, logins, and servers you never see. In this first lesson you'll create a real HTML file and open it in your browser — your first tiny website.
<!DOCTYPE html> <html> <head> <title>My First Page</title> </head> <body> <h1>Hello, Web!</h1> </body> </html>
Try it yourself
Change the <h1> text to your name and add a second line using <p>.
<h1>Hello, Sufyan!</h1> <p>This is my first web page.</p>
HTML Document Structure
12 minWhat you'll learn
- Learn the skeleton of every HTML page
- Understand head vs body
- Add metadata
Every HTML page follows the same skeleton: DOCTYPE tells the browser 'this is modern HTML', <head> holds invisible info like the title, and <body> holds everything visible. Understanding this structure means you'll never be lost in any HTML file.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page Title</title> </head> <body> <h1>Visible content lives here</h1> </body> </html>
Try it yourself
Add lang='en' to your <html> tag and a short description meta tag.
<html lang="en"> <head> <meta name="description" content="My learning page"> </head>
Headings & Paragraphs
10 minWhat you'll learn
- Use h1–h6 correctly
- Structure readable text with <p>
- Add line breaks
Headings create hierarchy: h1 is the main title (use it only once per page), h2 is a section, h3 a sub-section, down to h6. Paragraphs (<p>) hold your normal text. Good heading structure helps both readers and search engines understand your page.
<h1>My Blog</h1> <h2>Today's Post</h2> <p>This is my first blog post. It has two sentences.</p> <h3>Why I started coding</h3> <p>Because building things is fun!</p>
Try it yourself
Create a small page with one h1, one h2, and two paragraphs about your hobby.
<h1>Cooking</h1> <h2>Why I love it</h2> <p>It's relaxing.</p> <p>And delicious.</p>
Links & Navigation
12 minWhat you'll learn
- Create clickable links with <a>
- Link to pages and sections
- Open links safely
The anchor tag <a> turns text into a clickable link. The href attribute is the destination. Links are what make the web a web — connecting your page to others, to email, and even to specific parts of the same page.
<a href="https://example.com">Visit Example</a><br> <a href="#about">Jump to About</a> <h2 id="about">About Section</h2> <p>This is the about text.</p>
Try it yourself
Create two links: one to your favorite website and one that jumps to a section on the same page.
<a href="https://google.com">Google</a> <a href="#contact">Contact</a> <h2 id="contact">Contact</h2>
Images
10 minWhat you'll learn
- Embed images with <img>
- Understand alt text
- Control size
The <img> tag displays images. It's self-closing (no closing tag). The alt attribute describes the image for screen readers and shows if the image fails to load — it's also an SEO ranking signal, so write it carefully.
<img src="https://picsum.photos/300/200" alt="A random scenic photo" width="300" height="200" >
Try it yourself
Add an image of your choice and write a short descriptive alt text for it.
<img src="cat.jpg" alt="A sleeping orange cat on a window sill">
Lists: Ordered & Unordered
10 minWhat you'll learn
- Create bullet lists with <ul>
- Create numbered lists with <ol>
- Nest lists
Lists organize information. Unordered lists (<ul>) show bullets — great for features or ingredients. Ordered lists (<ol>) show numbers — perfect for steps. You can nest one list inside another for complex structures like menus.
<h2>Shopping List</h2> <ul> <li>Milk</li> <li>Eggs</li> <li>Bread</li> </ul> <h2>How to make tea</h2> <ol> <li>Boil water</li> <li>Add tea leaves</li> <li>Pour and enjoy</li> </ol>
Try it yourself
Create an ordered list of your morning routine and an unordered list of your hobbies.
<ol><li>Wake up</li><li>Brush teeth</li></ol> <ul><li>Reading</li><li>Gaming</li></ul>
HTML Forms Basics
15 minWhat you'll learn
- Build a simple form
- Use inputs and labels
- Add a submit button
Forms collect user input — the heart of sign-ups, search, and contact pages. Each input needs a <label> for accessibility. The type attribute controls what kind of input you get: text, email, password, and more.
<form action="/submit" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name"><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br> <button type="submit">Send</button> </form>
Try it yourself
Add a password input with a label to the form.
<label for="pass">Password:</label> <input type="password" id="pass" name="pass">
Semantic HTML Tags
12 minWhat you'll learn
- Use header, nav, main, footer
- Understand why semantics matter
- Improve SEO and accessibility
Semantic tags describe their meaning: <header> is the top, <nav> is navigation, <main> is core content, <footer> is the bottom. They don't look different, but they tell search engines and screen readers what each part of your page is for.
<header> <h1>My Site</h1> </header> <nav> <a href="/">Home</a> <a href="/about">About</a> </nav> <main> <p>Main content goes here.</p> </main> <footer> <p>© 2026 My Site</p> </footer>
Try it yourself
Convert a div-based layout into semantic tags (header, main, footer).
<header>Top area</header> <main>Main area</main> <footer>Bottom area</footer>
Introduction to CSS
15 minWhat you'll learn
- Link a stylesheet
- Style with selectors
- Change colors and text
CSS makes HTML look good. You select an element and apply rules: color, size, spacing, and more. The three ways to add CSS are inline, in a <style> tag, or — best practice — a separate .css file linked from your HTML.
/* style.css */
h1 {
color: navy;
font-family: Arial, sans-serif;
text-align: center;
}
p {
color: #444;
line-height: 1.6;
}
Try it yourself
Create a style.css that makes all h2 tags green and all paragraphs 18px.
h2 { color: green; }
p { font-size: 18px; }CSS Colors & Fonts
12 minWhat you'll learn
- Use color names, hex, and rgb
- Apply web-safe fonts
- Style text with weight and size
Colors in CSS can be named (red), hex (#ff0000), or rgb(255, 0, 0). Fonts control how text looks — use font-family for the typeface, font-size for how big, and font-weight for boldness. Good typography makes pages readable and professional.
body {
background: #f5f5f5;
color: #333;
font-family: 'Segoe UI', Tahoma, sans-serif;
}
h1 {
color: #4338ca;
font-weight: 700;
}
.accent {
color: rgb(255, 183, 3);
}
Try it yourself
Give the body a dark background with white text, and make a .highlight class yellow.
body { background: #111; color: white; }
.highlight { color: yellow; }The CSS Box Model
15 minWhat you'll learn
- Understand margin, border, padding, content
- Control spacing precisely
- Debug layout with box model
Every element is a box: content at the center, padding inside the border, border around padding, margin outside. Mastering this model is the difference between layouts that 'just work' and ones that mysteriously overflow.
.card {
width: 200px;
padding: 20px;
border: 2px solid #ccc;
margin: 10px;
border-radius: 8px;
}
Try it yourself
Create a box with 15px padding, 3px border, and 25px margin.
.box { padding: 15px; border: 3px solid black; margin: 25px; }Flexbox Layout
18 minWhat you'll learn
- Center content easily
- Arrange items in rows/columns
- Build responsive layouts
Flexbox is the modern way to lay out items in one dimension — a row or a column. With display:flex, you can center things (the old nightmare), space them evenly, and make layouts that adapt. It's the tool you'll use most in real projects.
.container {
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
height: 200px;
}
.box {
width: 50px;
height: 50px;
background: #4338ca;
border-radius: 8px;
}
Try it yourself
Use flexbox to put three boxes in a row with equal space between them.
.row { display: flex; justify-content: space-between; }Responsive Design with Media Queries
15 minWhat you'll learn
- Make pages mobile-friendly
- Use breakpoints
- Test responsive layouts
Responsive design means your site looks great on phones, tablets, and desktops. Media queries apply different CSS at different screen widths. A common breakpoint is 768px — below that, stack columns; above, show them side by side.
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
}
@media (max-width: 768px) {
.grid {
grid-template-columns: 1fr;
}
}
Try it yourself
Add a media query that turns a flex row into a column below 600px.
@media (max-width: 600px) {
.container { flex-direction: column; }
}Introduction to JavaScript
15 minWhat you'll learn
- Add interactivity to pages
- Run your first script
- Understand what JS does
JavaScript makes pages interactive — clicks, animations, form checks, fetching data. It runs in the browser via a <script> tag. HTML is the skeleton, CSS the skin, and JavaScript the muscles that make things move.
<script>
alert('Hello, World!');
console.log('This appears in the console');
</script>
Try it yourself
Change the alert message and log your name to the console.
alert('Hi!');
console.log('Sufyan');JavaScript Variables & Data Types
15 minWhat you'll learn
- Declare variables with let/const
- Understand strings and numbers
- Use basic operators
Variables store data. Use const for values that never change, let for values that do (avoid var — it's outdated). Main data types are strings (text in quotes), numbers, booleans (true/false), and arrays (lists).
const name = 'Sufyan'; let age = 21; age = age + 1; const isStudent = true; console.log(name, age, isStudent);
Try it yourself
Create a const for your city and a let for your score, then add 5 to the score.
const city = 'Lahore'; let score = 10; score += 5; console.log(city, score);
JavaScript Functions
15 minWhat you'll learn
- Write reusable functions
- Pass arguments and return values
- Avoid repeating code
Functions bundle code into reusable blocks. You define them once and call them anywhere — passing in arguments and getting back return values. Functions are how you keep code DRY (Don't Repeat Yourself).
function greet(name) {
return 'Hello, ' + name + '!';
}
const message = greet('Sufyan');
console.log(message);
Try it yourself
Write an add() function that takes two numbers and returns their sum.
function add(a, b) { return a + b; }
console.log(add(2, 3)); // 5DOM Manipulation
18 minWhat you'll learn
- Select elements with querySelector
- Change text and styles
- Add and remove content
The DOM (Document Object Model) is how JavaScript sees your HTML. With document.querySelector() you can grab any element and change its text, class, or style. This is how every dynamic website updates content without reloading.
const heading = document.querySelector('h1');
heading.textContent = 'Updated title';
heading.style.color = 'green';
const btn = document.querySelector('button');
btn.textContent = 'Clicked!';
Try it yourself
Select a paragraph and change its text to 'I learned DOM!'.
document.querySelector('p').textContent = 'I learned DOM!';JavaScript Events
18 minWhat you'll learn
- Handle clicks and input
- Use addEventListener
- Build interactive UI
Events are things that happen — clicks, typing, hovering. With addEventListener you run code when an event fires. This is the heart of interactivity: every button, form, and menu you've ever used works this way.
const button = document.querySelector('button');
button.addEventListener('click', function() {
alert('Button clicked!');
});
const input = document.querySelector('input');
input.addEventListener('input', function() {
console.log('You typed:', input.value);
});
Try it yourself
Add a click event to a button that changes its own text.
btn.addEventListener('click', () => { btn.textContent = 'Done'; });Developer Tools & Debugging
12 minWhat you'll learn
- Open DevTools (F12)
- Inspect elements and styles
- Use the console for errors
DevTools is your superpower. Right-click anything → Inspect to see its HTML and CSS. The Console shows errors and your console.log output. Learning to debug with DevTools saves hours of guessing when something doesn't look or work right.
console.log('Checkpoint 1');
console.error('This is an error message');
console.table([{name:'A', age:1},{name:'B', age:2}]);
Try it yourself
Open DevTools, inspect any element on your page, and change its color live.
No code — this is a hands-on DevTools exercise.
Capstone: Personal Profile Page
30 minWhat you'll learn
- Combine HTML, CSS, and JS
- Build a complete responsive page
- Publish your first real project
Time to put everything together. You'll build a personal profile page: a header with your name, a photo, an about section, a list of skills, and a button that reveals a fun fact using JavaScript — all responsive with CSS.
<!DOCTYPE html>
<html>
<head>
<title>My Profile</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Sufyan Khan</h1>
</header>
<main>
<img src="me.jpg" alt="My photo">
<h2>About</h2>
<p>I'm learning web development on DocoDive.</p>
<h2>Skills</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<button id="funBtn">Click for a fun fact</button>
<p id="fact"></p>
</main>
<script src="script.js"></script>
</body>
</html>
Try it yourself
Add a script.js that shows a fun fact when the button is clicked.
document.getElementById('funBtn').addEventListener('click', () => {
document.getElementById('fact').textContent = 'I can code a whole page!';
});Beginner Projects
Apply everything you've learned. Click each project to open its full guide.
About this project
Build a beautiful recipe card using pure HTML and CSS. You'll lay out a food image, list ingredients, and write cooking steps in a clean, readable card that looks like a real recipe site.
What you'll practice
Step-by-step: How it works
- Create a
divwith classrecipe-card. - Add an
imgat the top for the dish photo. - Use
h2for the recipe name. - List ingredients in a
uland steps in anol. - Style with padding, border-radius, and shadow.
- Use Flexbox to center the card.
<!DOCTYPE html>
<html>
<head>
<title>Recipe Card</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #f0fdf4;
font-family: Arial, sans-serif;
}
.recipe-card {
width: 320px;
background: white;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.recipe-card img {
width: 100%;
height: 180px;
object-fit: cover;
}
.recipe-content { padding: 20px; }
h2 { margin: 0 0 8px; color: #166534; }
</style>
</head>
<body>
<div class="recipe-card">
<img src="https://picsum.photos/320/180" alt="A delicious dish">
<div class="recipe-content">
<h2>Spicy Noodles</h2>
<p>Quick 10-minute meal.</p>
<h3>Ingredients</h3>
<ul><li>Noodles</li><li>Chili sauce</li><li>Garlic</li></ul>
<h3>Steps</h3>
<ol><li>Boil noodles.</li><li>Stir-fry garlic.</li><li>Mix and serve.</li></ol>
</div>
</div>
</body>
</html>
Spicy Noodles
About this project
Build a page with a button that changes the background to a random color every time it's clicked — your first real JavaScript interactivity.
What you'll practice
Step-by-step
- Select the button with
querySelector. - Attach a
clickevent. - Generate three random RGB values (0–255).
- Set
body.style.backgroundColor.
<!DOCTYPE html>
<html>
<head>
<title>Color Changer</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
transition: background 0.3s ease;
}
button {
padding: 14px 28px;
border: none;
border-radius: 50px;
cursor: pointer;
background: #1e1b4b;
color: white;
font-weight: 600;
}
</style>
</head>
<body>
<button id="changeColor">Change Color</button>
<script>
const btn = document.querySelector("#changeColor");
btn.addEventListener("click", function() {
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
document.body.style.backgroundColor = 'rgb(' + r + ',' + g + ',' + b + ')';
});
</script>
</body>
</html>
Animating — each click changes this color
About this project
Build a minimal to-do list — type a task, click Add, and it appears below. Combines DOM manipulation, events, and dynamic content.
What you'll practice
Step-by-step
- Select input, button, and list.
- On click, read and trim input value.
- Create an
li, set text, append. - Add a remove button that deletes the task.
<!DOCTYPE html>
<html>
<head>
<title>To-Do List</title>
<style>
body { max-width: 400px; margin: 40px auto; font-family: Arial; }
.input-row { display: flex; gap: 8px; margin-bottom: 16px; }
input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 8px; }
button { padding: 10px 16px; background: #0d9488; color: white; border: none; border-radius: 8px; cursor: pointer; }
ul { list-style: none; padding: 0; }
li { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid #eee; }
.remove { background: #fee2e2; color: #dc2626; padding: 4px 10px; }
</style>
</head>
<body>
<h1>My To-Do List</h1>
<div class="input-row">
<input id="taskInput" type="text" placeholder="Add a task...">
<button id="addTask">Add</button>
</div>
<ul id="taskList"></ul>
<script>
const input = document.querySelector("#taskInput");
const addBtn = document.querySelector("#addTask");
const list = document.querySelector("#taskList");
addBtn.addEventListener("click", function() {
const text = input.value.trim();
if (!text) return;
const li = document.createElement("li");
li.textContent = text;
const removeBtn = document.createElement("button");
removeBtn.textContent = "Remove";
removeBtn.className = "remove";
removeBtn.addEventListener("click", () => li.remove());
li.appendChild(removeBtn);
list.appendChild(li);
input.value = "";
});
</script>
</body>
</html>
My To-Do List
You've completed all 20 lessons. Ready to level up?
Continue to Web Development Intermediate to master layouts, JavaScript, and APIs.