Table of Contents
1. Introduction
If front-end development were compared to building a house, then:
- HTML is the skeleton and structure of the house — the walls, floors, and ceiling
- CSS is the decoration and finishing — paint, wallpaper, furniture placement
- JavaScript is the plumbing, electrical system, and smart home features — turning lights on and off, adjusting temperature, automated curtains
Each of the three has its own role, and none can be missing. Once you understand this trio, you’ve got your ticket into the front-end world.
2. HTML: The Skeleton of a Webpage
2.1 What Is HTML?
HTML (HyperText Markup Language) uses tags to describe the structure and content of a page. It doesn’t care about whether things look good — only about “what’s there” and “what it is.”
<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>My First Webpage</title></head><body> <header> <h1>Welcome to my website</h1> <nav> <a href="/">Home</a> <a href="/about">About</a> </nav> </header> <main> <article> <h2>Article Title</h2> <p>This is a paragraph of body text.</p> </article> </main> <footer> <p>© 2026 My Website</p> </footer></body></html>2.2 Common HTML Tags
| Category | Tags | Purpose |
|---|---|---|
| Structure | <header>, <main>, <footer>, <nav>, <article>, <section> | Semantic layout |
| Headings | <h1> ~ <h6> | Six heading levels, h1 is the most important |
| Text | <p>, <span>, <strong>, <em> | Paragraphs, inline text, bold, emphasis |
| Links | <a href="..."> | Hyperlinks |
| Media | <img>, <video>, <audio> | Images, video, audio |
| Lists | <ul>, <ol>, <li> | Unordered lists, ordered lists |
| Forms | <form>, <input>, <button>, <select> | User input |
| Containers | <div> | Generic block-level container |
2.3 Semantic HTML
Semantic HTML means using the right tags to describe the right content, rather than filling the screen with <div>:
<!-- ❌ Not recommended: all divs --><div class="header"> <div class="title">Title</div></div>
<!-- ✅ Recommended: use semantic tags --><header> <h1>Title</h1></header>Benefits of semantic HTML:
- SEO: Search engines understand page content better
- Accessibility: Screen readers can accurately convey information to visually impaired users
- Maintainability: Clearer code structure makes team collaboration easier
3. CSS: The Skin of a Webpage
3.1 What Is CSS?
CSS (Cascading Style Sheets) handles the visual presentation of a webpage: colors, fonts, spacing, layout, animations, and more.
/* selector { property: value; } */body { font-family: 'Inter', sans-serif; background-color: #f5f5f5; color: #333; line-height: 1.6;}
h1 { font-size: 2rem; font-weight: 700; color: #1a1a2e;}
.card { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);}3.2 Core Concepts
Selectors
/* element selector */p { }
/* class selector (most commonly used) */.card { }
/* ID selector */#header { }
/* combinator selectors */.card:hover { }nav > a { }input[type="text"] { }The Box Model
Every element is a rectangular box, and from the inside out it consists of:
| Layer | Property | Description |
|---|---|---|
| content | width / height | Content area |
| padding | padding | Inner spacing (content to border) |
| border | border | Border |
| margin | margin | Outer spacing (element to element) |
.box { width: 300px; padding: 20px; border: 1px solid #ddd; margin: 16px; /* actual occupied width = 300 + 20×2 + 1×2 + 16×2 = 374px */}Layout: Flexbox and Grid
/* Flexbox: one-dimensional layout */.container { display: flex; justify-content: space-between; /* horizontal distribution */ align-items: center; /* vertical centering */ gap: 16px; /* spacing */}
/* Grid: two-dimensional layout */.grid { display: grid; grid-template-columns: repeat(3, 1fr); /* three equal-width columns */ gap: 24px;}Responsive Design
/* mobile-first */.card { width: 100%;}
/* tablet */@media (min-width: 768px) { .card { width: 50%; }}
/* desktop */@media (min-width: 1024px) { .card { width: 33.33%; }}4. JavaScript: The Brain of a Webpage
4.1 What Is JavaScript?
JavaScript (JS for short) is a dynamic, weakly typed scripting language that brings webpages to life. It runs in the browser and can manipulate HTML and CSS and respond to user interactions.
// Click the button to toggle the themeconst button = document.querySelector('#theme-toggle');const body = document.body;
button.addEventListener('click', () => { body.classList.toggle('dark-mode'); const isDark = body.classList.contains('dark-mode'); button.textContent = isDark ? '☀️ Light mode' : '🌙 Dark mode';});4.2 Core Concepts at a Glance
Variables and Scope
// let: mutable variable (block scope)let count = 0;count += 1;
// const: immutable constant (block scope)const API_URL = 'https://api.example.com';
// var: legacy syntax, has hoisting issues, not recommendedvar oldWay = 'Do not write it like this';Data Types
| Type | Example | Description |
|---|---|---|
| Number | 42, 3.14, NaN | All numbers are floating-point |
| String | 'hello', "世界", `template` | Text |
| Boolean | true, false | Logical values |
| Object | { name: 'Alice', age: 25 } | Key-value pairs |
| Array | [1, 2, 3] | Ordered list |
| Function | function() {} / () => {} | Callable object |
| Undefined | undefined | Undefined |
| Null | null | Null value |
DOM Manipulation
// Query elementsconst el = document.querySelector('.card');const els = document.querySelectorAll('.card');
// Modify contentel.textContent = 'New text';el.innerHTML = '<strong>Bold text</strong>';
// Modify stylesel.style.backgroundColor = '#f0f0f0';el.classList.add('active');el.classList.remove('hidden');
// Create and insert elementsconst newDiv = document.createElement('div');newDiv.textContent = 'I am a new element';document.body.appendChild(newDiv);Asynchronous Programming
// Promisefetch('https://api.example.com/data') .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err));
// Async / Await (the more recommended approach)async function fetchData() { try { const res = await fetch('https://api.example.com/data'); const data = await res.json(); console.log(data); } catch (err) { console.error('Request failed:', err); }}5. How the Three Work Together
A real front-end page is a collaborative work of HTML, CSS, and JavaScript:
<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>Trio collaboration example</title> <!-- CSS --> <style> body { font-family: sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; } .counter { display: flex; align-items: center; gap: 16px; } #count { font-size: 2rem; font-weight: bold; } button { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; } .plus { background: #4CAF50; color: white; } .minus { background: #f44336; color: white; } </style></head><body> <h1>Counter</h1> <!-- HTML: structure --> <div class="counter"> <button class="minus" onclick="decrement()">-</button> <span id="count">0</span> <button class="plus" onclick="increment()">+</button> </div>
<!-- JavaScript: behavior --> <script> let count = 0; const countEl = document.getElementById('count');
function increment() { count++; countEl.textContent = count; }
function decrement() { count--; countEl.textContent = count; } </script></body></html>See that? HTML builds the frame, CSS paints the look, and JavaScript gives it a brain. Each of the three has its own role, and together they make up every web page you see in your browser.
6. Suggested Learning Path
| Stage | Content | Suggested Duration |
|---|---|---|
| Beginner | Common HTML tags + CSS selectors + JS variables and functions | 2–3 weeks |
| Intermediate | CSS layout (Flex/Grid) + JS DOM manipulation + events | 3–4 weeks |
| Practical | Responsive design + AJAX/Fetch + ES6 syntax | 4–6 weeks |
| Frameworks | React or Vue (pick one to start) | 8–12 weeks |
Advice: Don’t try to learn everything at once. First master HTML and CSS to build static pages, then learn JavaScript to add interactivity, and only then move on to frameworks. The more solid your fundamentals, the easier frameworks will be to learn.
7. Summary
HTML, CSS, and JavaScript—this “holy trinity”—are the cornerstones of front-end development. No matter what frameworks you use later (React, Vue, Angular) or what tools you write with (Webpack, Vite), the final output is always these three things.
Just remember this analogy: HTML is the skeleton, CSS is the skin, and JavaScript is the soul.