Three Languages, One Webpage — 三种语言,一个网页
🇨🇳 中文
每个网页都是用三种语言一起做出来的。可以把它们想象成一个三层蛋糕:
- HTML — 内容和
structure (骨头) - CSS — 样式和外观(衣服)
- JavaScript — 互动和动作(让它会动)
这一节课,我们快速学完三种基础。学完之后你能自己写一个简单网页。
🇬🇧 English
Every webpage is built with three languages working together. Think of them as a three-layer cake:
- HTML — content and
structure (the bones) - CSS — style and looks (the clothes)
- JavaScript — interaction and behavior (makes it move)
In this lesson we cover the basics of all three. After it, you can write a simple webpage yourself.
Why learn these three? — 为什么学这三种?
中文: HTML、CSS、JavaScript 是所有网页都用的标准。学会了它们,你就能看懂任何网页背后的代码,自己做网站,找前端
English: HTML, CSS, and JavaScript are the universal standard for every webpage. Once you learn them, you can read any website's code, build your own site, get a frontend job, or just have fun. They're also the foundation for advanced frameworks like React and Vue.
Setup: All You Need — 你需要的全部工具
🇨🇳 中文
好消息:你不需要买任何东西,也不需要安装复杂的软件!
🇬🇧 English
Good news: you don't need to buy anything or install complicated software!
Download VS Code free, or use Windows Notepad.
Chrome, Firefox, or Edge — already on your computer.
my-website 来放你的代码文件。Make a folder on your desktop called
my-website.💡 How to Run Your Code — 怎么运行你的代码
中文: 在 VS Code(或记事本)里写完代码,保存文件(文件名 index.html),然后双击那个文件 — 浏览器会自动打开你的网页!
English: Write your code in VS Code (or Notepad), save the file as index.html, then double-click the file — your browser opens it automatically!
Part 1: HTML — The Bones — HTML 是骨头
🇨🇳 中文
HTML 的全称是 HyperText Markup Language(
每个标签都长这样:<tagname>内容</tagname>
🇬🇧 English
HTML stands for HyperText Markup Language. It uses tags to describe what's on the page — headings, paragraphs, images, links, and more.
Every tag looks like this: <tagname>content</tagname>
🦴 The Skeleton — 基本骨架
Every HTML file starts the same way / 每个 HTML 文件都这样开头:
🇨🇳 中文 — 解释
<!DOCTYPE html>— 告诉浏览器"这是 HTML5"<html>— 整个页面的最外层<head>— 看不见的设置(标题、字符编码)<body>— 看得见的内容(你写的所有东西)
🇬🇧 English — Explanation
<!DOCTYPE html>— Tells the browser "this is HTML5"<html>— The outer wrapper for the whole page<head>— Invisible settings (title, character encoding)<body>— The visible content (everything you write)
📝 Common Tags — 常用标签
<h1> 最大,<h6> 最小。每页通常只有一个 <h1>。h1 is biggest, h6 is smallest. Usually one h1 per page.
<p>Hello!</p><a href="https://google.com">Google</a><img src="cat.jpg" alt="A cat"><li>。Bullet list with li items inside ul.
<strong> = 重要,<em> = 强调。strong = important, em = emphasis.
🎯 Try It — 动手试试
Save this as index.html and double-click to open in your browser:
把下面的代码保存成 index.html,双击在浏览器里打开:
Hello, I am Li Ming
I am learning HTML and English.
My favorite things:
- Coding
- Tea
- Movies
⚠️ Common Mistakes — 常见错误
- 忘记关标签 / Forgetting the closing tag — every
<p>needs a</p>/ 每个<p>都要有</p> - 大小写 / Wrong case — HTML tags are usually lowercase / 一般用小写
- 引号 / Missing quotes — attribute values need quotes:
href="..."/ 属性值要加引号
Part 2: CSS — The Clothes — CSS 是衣服
🇨🇳 中文
CSS 的全称是 Cascading Style Sheets(
CSS 的语法:选择器 { 属性: 值; }
🇬🇧 English
CSS stands for Cascading Style Sheets. It tells the browser what your HTML elements should look like — colors, sizes, fonts, spacing, layout.
The syntax is: selector { property: value; }
📍 Three Places to Put CSS — CSS 放在哪三个地方
1 Inline — 行内(在标签里)
Quick but messy / 简单但乱:
2 Internal — 内部(在 head 里)
Good for one-page sites / 适合单页网站:
3 External — 外部(独立文件,最好)
Best for multi-page sites / 多页网站最佳选择。Save CSS in style.css, link it in HTML:
🎯 Selectors — 选择器
🇨🇳 中文
选择器告诉浏览器"给哪些元素加样式"。三种最常用:
🇬🇧 English
Selectors tell the browser "which elements to style." Three most common:
💡 Class vs ID — 类 vs ID
中文: Class(.)可以重复用很多次,ID(#)一个页面只能用一次。一般情况下都用 class。
English: Classes (.) can be reused many times. IDs (#) can only appear once per page. In most cases, use classes.
🎨 Common Properties — 常用属性
color: red; 或 color: #ff0000; 或 color: rgb(255,0,0);background: lightblue;background: url(bg.jpg);font-size: 16px; 或 font-size: 1.2em;font-family: 'Arial', sans-serif;padding: 10px; — 上下左右都 10pxmargin: 20px; — 元素外面留 20px 空间border: 2px solid black;text-align: center; 或 left、right📦 The Box Model — 盒子模型
🇨🇳 中文
每个 HTML 元素都是一个"盒子",从内到外有四层:内容 → padding(内边距)→ border(边框)→ margin(外边距)
🇬🇧 English
Every HTML element is a "box" with four layers from inside out: content → padding → border → margin
内容
🎯 Try It — 动手试试
Add this CSS to the HTML from Part 1 (inside <head>):
把下面的 CSS 加到 Part 1 的 HTML 里(放在 <head> 里面):
Part 3: JavaScript — The Movement — JavaScript 是动作
🇨🇳 中文
JavaScript(简称 JS)让网页"动起来"。当用户点击按钮、输入文字、滚动页面时,JS 决定发生什么。
注意:JavaScript 和 Java 是完全不同的语言!只是名字像。
🇬🇧 English
JavaScript (JS for short) makes a webpage "come alive." When a user clicks a button, types something, or scrolls, JS decides what happens.
Note: JavaScript and Java are completely different languages! The names are just similar.
📍 How to Add JS — 怎么加 JS
Two common ways / 两种常见方式:
💡 Where to Put It — 放在哪里
中文: <script> 标签通常放在 <body> 的最后(关闭 </body> 之前)— 这样浏览器先加载 HTML,JS 才能找到要操作的元素。
English: Put <script> at the end of <body> (just before </body>) so the browser loads HTML first, then JS can find the elements.
📝 Variables — 变量
🇨🇳 中文
变量就是给一个值起名字。用 let(可以改)或 const(不能改)。
🇬🇧 English
A variable gives a name to a value. Use let (can change) or const (cannot change).
🔧 Functions — 函数
🇨🇳 中文
函数是一块可以重复使用的代码。给它输入,它返回结果。
🇬🇧 English
A function is a reusable block of code. You give it input, it returns a result.
🖱️ The DOM — 操作网页元素
🇨🇳 中文
DOM(
🇬🇧 English
The DOM (Document Object Model) is how the browser turns HTML into "objects." JS uses the DOM to find elements, change text, and respond to events.
🎯 Try It — 动手试试 (interactive!)
Click the button below — it's running real JavaScript:
点下面的按钮 — 真的 JavaScript 在运行:
(button output appears here / 按钮的输出显示在这里)
The code behind it / 背后的代码:
Mini Project: A Complete Page — 综合小项目
🇨🇳 中文
把三种语言放在一起,做一个完整的小网页。复制下面的代码,保存成 index.html,双击打开:
🇬🇧 English
Now let's combine all three languages into a complete page. Copy the code below, save as index.html, and double-click to open:
🎯 Live Demo — 实时演示
My Counter — 我的计数器
0
🎉 You can read all three! — 你能读懂三种语言!
You now know the basics of HTML, CSS, and JavaScript. Every webpage in the world uses these. Keep building small projects — that's how you really learn.
你现在懂了 HTML、CSS、JavaScript 的基础。世界上每个网页都用它们。不停地做小项目 — 这才是真正学会的方法。
Useful English Phrases — 实用英语句子
Glossary — 词汇表
<p>.HTML 中包裹内容的部分,比如
<p>。网页上一个完整的单元 — 开始标签 + 内容 + 结束标签。
href="..." on a link.标签上的额外信息,比如链接上的
href="..."。CSS 里告诉浏览器"哪些元素"的部分 — 元素、类或 id。
color, font-size.CSS 里你要改的东西 — 比如
color、font-size。let or const.JavaScript 中存值的名字。用
let 或 const。可以重复使用的一段代码 — 接受输入,返回输出。
HTML 页面的对象形式,JS 可以读取和修改。
发生的事情 — 点击、输入、滚动、页面加载。
.classname in CSS.HTML 元素上可重用的标签。CSS 里用
.classname 选中。浏览器开发者工具,JS 消息显示在这里。按 F12 打开。
找出并修复代码里的问题。
Quick Checklist — 检查清单
HTML — 结构
CSS — 样式
JavaScript — 互动
Keep Building. — 继续做下去。
Read other people's code. Break things. Fix them. That's how every developer learns.
读别人的代码。弄坏它。修好它。每个程序员都是这样学会的。