Web Programming Reference
HTML · CSS · JavaScript · Regular Expression
224 topics
Reference scope: Lab 1–9(HTML、CSS、JavaScript)。Lab 7–9 新增 JavaScript Basics、Event-driven Programming 同 Client-side Form Validation;補充例子、教材不明確之處及拼寫修正已標明。Regular Expression 部分另外收錄常見格式練習。
HTML
| 知識點 / Topic | 內容 / Syntax & Example |
|---|---|
| HTML document structure | |
| Heading / h1–h6 | |
| Paragraph / line break / horizontal rule | |
| Whitespace / non-breaking space | |
| Heading alignment (legacy HTML) | Example 1 Example 2 Example 3 Lab 1 使用舊式 align;現代 HTML 建議用 CSS。 |
| Hyperlink / href | |
| Email hyperlink / mailto | |
| Image as hyperlink | |
| Unordered list / ul / li | |
| Ordered list / ol / li | |
| Definition list / dl / dt / dd | |
| Table / tr / td / th | |
| Table width / height / cell width (legacy) | |
| Table cell alignment / valign (legacy) | Example 1 Example 2 Example 3 Example 4 Example 5 Lab 2:水平 align;垂直 valign。現代用 text-align 同 vertical-align。 |
| Table colspan / merge columns | |
| Table rowspan / merge rows | |
| Image inside table cell | |
| Iframe / embedded page | |
| Two iframe layout / menu and content | Main page Menu page Lab 2 Additional Exercise:20% menu、80% content;高度同 target 連動係補充例子。 |
| Audio / music | |
| Video | |
| Strong / emphasis | |
| Hidden input | |
| Telephone input / tel | |
| Range input / slider | |
| Date range / start and end dates | |
| Separate checkbox names | |
| Single select / option | |
| Form / GET / POST | |
| File upload | |
| Number input | |
| Required field | |
| Radio buttons | |
| Checkbox | |
| Select / multiple / optgroup | |
| Textarea | |
| Submit / Reset / Button | Example 1 Example 2 Example 3 reset 恢復初始值;button 本身唔會提交表單。 |
| Image | |
| Pattern / character length | Example 1 Example 2 pattern=".{6}" 要求剛好六個字元(一般單行文字);required 防止留空。 |
| Date / Color | Example 1 Example 2 使用瀏覽器內置選擇器。 |
| Output / oninput | |
| Submit event | |
| Default value / value | |
| Placeholder | |
| Disabled / readonly | Example 1 Example 2 disabled 唔可以操作,亦唔會提交;readonly 仍可提交。 |
| File type / accept | |
| Fieldset / Legend | |
| Default selected option | |
| Numeric / alphabetic pattern | Example 1 Example 2 Example 3 分別限制六個數字、英文字母、英文字母或數字;按要求選用。 |
| Named output / form oninput | |
| Label / id / name | |
| External CSS / JavaScript | Example 1 Example 2 連接外部文件;defer 令 script 喺 HTML 解析完成後執行。 |
| POST / multipart form / HTTPS | |
| Radio group / default booking option | |
| Textarea dimensions / initial text | |
| Integer number range / rating | |
| Color picker / reset to defaults | |
| Named iframe / link target | |
| Nested list / submenu | |
| Password input / retype | |
| Pattern / capital first character | |
| Number / minimum age | |
| URL input / valid URL | |
| Pattern / time HH:MM:SS | |
| Pattern / hexadecimal color code | |
| Radio group / required selection | |
| Checkbox group / same name | |
| Select / empty placeholder option | |
| Validation hint / title | |
| Disable native validation / novalidate | |
CSS
| 知識點 / Topic | 內容 / Syntax & Example |
|---|---|
| Inline CSS / local style sheet | |
| Internal CSS / global style sheet | |
| External CSS / linked style sheet | HTML head style.css Lab 4 Q3:HTML 同 CSS 分開保存;href 必須同實際 CSS 文件名相符。 |
| Element selector / type selector | |
| Grouping selector / comma | |
| Contextual / descendant selector | |
| Class selector / dot | CSS HTML Lab 4 Q5:class selector 用 .;同一個 class 可以重複使用。CSS 同 HTML 分別放入相應位置。 |
| ID selector / hash | CSS HTML Lab 4 Q6:ID selector 用 #;同一頁嘅 ID 應該唯一。 |
| Font size units / px / pt / percent | |
| Font family / fallback fonts | |
| Hyperlink underline / text-decoration | |
| Pseudo-element / first-letter / drop caps | Lab syntax Modern CSS Lab 4 Q7c:每段首字放大至正常字體三倍;兩種 selector 寫法都適用。 |
| List style type | |
| Table borders / collapse / spacing | |
| Table vertical alignment | |
| CSS cascade / specificity / inheritance | |
| Flex container / wrapping | |
| Flex direction / alignment | |
| Flex item / order / grow / shrink | |
| Full width / fixed width | |
| Display / visibility | |
| Font / text alignment | |
| Multiple columns | |
| Float / clear | |
| Media query | |
| Selectors | |
| Text alignment | Example 1 Example 2 Example 3 Example 4 四種替代寫法;按要求選其中一個。 |
| Flex direction / wrap alternatives | Option A Option B column 垂直排列;row 水平排列。 |
| Justify content | Example 1 Example 2 Example 3 Example 4 Example 5 Example 6 主軸對齊替代值;space-between 兩端無額外空隙,around 每項兩側有空隙,evenly 所有空隙相等。 |
| Align items / align self | |
| Margin | Example 1 Example 2 Example 3 外邊距;四值順序 top right bottom left;auto 可配合固定闊度水平置中。 |
| Padding | Example 1 Example 2 內邊距;兩值順序上下、左右。 |
| Border / radius | |
| Box shadow / box sizing | |
| Background color / color | |
| Font family / weight / style | |
| Responsive order / flex basis | |
| Image size / responsive image | |
| Visibility / display alternatives | |
| Responsive flex / float reset | |
| List reset / inline-block menu | |
| Block links / padding / line-height | |
| Text shadow / box shadow | |
| Nested hover / selector specificity | |
| Position / relative and absolute | |
| Overflow / clipping / scrolling | Option A Option B Lab 5 Q1(f)、Q2(b):hidden 裁剪超出範圍嘅內容;auto 有需要時先出現 scrollbar。 |
| Transition / animated submenu | |
| Transform / translate / rotate | Option A Option B Lab 5 Q1(d)、Q2(b):translate 移動元素相對原本位置;rotate 負角度逆時針。兩個 transform declaration 會覆蓋,要組合就放同一行。 |
| Transform / scale / skewY | |
| Absolute positioning + translate coordinates | |
| Stacking order / z-index | |
| Flex layout / desktop structure | |
| Responsive breakpoints / cascade / order | |
| Float image / margin-right / clear | |
| Three columns / spanning heading / vendor prefix | |
| Line height / unitless vs em | Option A Option B Lab 5 Q1(b)、Lab 6(l):1.2em 係目前字體大小嘅 1.2 倍;無單位值可按後代元素自己嘅字體大小計算。 |
| Responsive viewport / narrow main (supplement) | |
JavaScript
| 知識點 / Topic | 內容 / Syntax & Example |
|---|---|
| Get form / input value | Named form elements Alternative shorthand .value 一般回傳字串;用 Number(value) 轉成數字。 |
| Get element by ID | |
| Radio / Checkbox checked | |
| Select options / length | |
| For loop / selected | |
| String concatenation / newline | |
| Function / return false | |
| Event / calculation | |
| Form by ID / named elements | |
| Get elements by name | |
| Number conversion | |
| Radio group value | |
| Update text / HTML | |
| Confirm dialog | |
| Selected index / selected options | |
| Events / event listener | JavaScript listener HTML alternative input 即時觸發;change 通常喺更改完成後觸發。 |
| Complete form processing example | |
| Script / document.write / HTML markup | |
| Alert / window.alert / newline | |
| Button onclick / JavaScript pseudo-URL | |
| Prompt / window.prompt / cancel | |
| Image onclick / function argument | |
| Function / parameter / return value | |
| Math.PI / Math.pow / sphere volume | |
| toFixed / decimal places | |
| String addition vs numeric addition | |
| isNaN / if else / numeric validation | |
| do while / repeated prompt / getNum | |
| Comparison / logical operators | |
| Event handlers / onload onclick onchange oninput onkeyup onsubmit | |
| Form validation / blank username / password match | |
| Disabled property / enable disable controls | |
| Focus / focus() | |
| Form reset / reset() | |
| Select selectedIndex / selected option value | |
| Loop / enable or disable radio group | |
| Order calculation / initialize and total price | |
| Order price / quantity / shipping callback | |
| Order form / event wiring | |
| Named form / field value and name collision | |
| Radio group / loop and checked value | |
| Checkbox group / collect values / count | |
| Single select / selected value | |
| Form processing / display all field values | |
| Custom validation / setCustomValidity() | |
| Integer validation / Number.isInteger() | |
Regular Expression / Regex
HTML pattern 語法速查。Lab 3、9 已有電話、首字母、時間同色碼要求;以下其他格式係通用補充練習,唔係已確認考題。每個例子按實際題目調整長度、字元同 required。
| 知識點 / Topic | 內容 / Syntax & Example |
|---|---|
| HTML pattern / full match / required | Example 1 Example 2 pattern 驗證完整輸入,毋須加 ^ 同 $;唔好加 /.../。冇 required 時空字串可以通過;有 required 就唔可以留空。輸入唔符合時通常係阻止表單提交,唔係阻止輸入。 |
| Regex character classes / 字元種類 | |
| Regex quantifiers / 次數與長度 | |
| Regex grouping / alternatives / anchors / escape | |
| Exactly 6 characters / fixed length | |
| Exactly 6 digits / PIN | |
| Digits only / one or more | |
| Maximum 8 digits / telephone | |
| Exactly 8 digits / Hong Kong phone format | |
| Phone with optional country code / +852 | |
| English letters only / alphabetic | |
| Uppercase letters only | |
| Lowercase letters only | |
| Letters or digits / alphanumeric | |
| Alphanumeric / exactly 6 characters | |
| Length range / 4 to 10 letters | |
| At least 8 characters / minimum length | |
| Capital first character / starts with uppercase | |
| Capitalized word / first uppercase then lowercase | |
| Full name / letters and spaces | |
| Starts with A / ends with Z | |
| Student ID / prefix and digits | |
| Mixed format / 2 uppercase letters + 4 digits | |
| Username / letters, digits and underscore | |
| Username with literal hyphen / underscore | |
| Non-blank text / reject whitespace only | |
| No whitespace / one or more characters | |
| Time format / HH:MM:SS only | |
| Valid 24-hour time / HH:MM:SS | |
| Date format / YYYY-MM-DD | |
| Hex color / 3 or 6 hexadecimal digits | |
| Decimal / optional fractional part | |
| Price / exactly two decimal places | |
| Alternative values / OR / repeated group | |
| Password / at least 8 with letters and digits | |
| Password / uppercase lowercase digit | |
| Email / URL / number / date native validation | Example 1 Example 2 Example 3 Example 4 Lab 9(b–c) 用 HTML 原生 input type;Email 係補充。唔需要為基本 email / URL 自行寫複雜 regex;type="email" 唔代表郵箱真實存在。type="number" 唔支援 pattern,應用 min/max/step。 |
| Simple email format / when regex is explicitly requested | |
| JavaScript RegExp / test() / anchors | |
| JavaScript RegExp / constructor / escaping | |
| HTML validation / checkValidity() / patternMismatch | |
| Exactly 10 characters / fixed length | |
| Optional prefix / HK | |
| Positive integer / no leading zero | |
| Signed integer / optional plus minus | |
| Hong Kong mobile number / simplified format | |
| Postal code / five digits | |
| Letters followed by digits | |
| At least one uppercase letter / lookahead | |
| At least one special character / lookahead | |
| Email / domain labels and dot (simplified stricter) | |