按 ESC 概覽
任何文字編輯器
點兩下。
用瀏覽器「瀏覽」
file://...
"Markup Language":標記語言
"Markup":標籤
每個人都應該努力培養雅量。
<p>每個人都應該努力培養<strong>雅量</strong>。</p>
<p>
標出「段落」
<strong>
標出「重點」
HTML:勾勒內容與結構的「Formatting Language」
標籤、元素、屬性
<標籤名 屬性1="值1" 屬性2="值2">內容</標籤名>
標籤、元素、屬性
<label for="chk-tos">
:for
attribute 的 Start tag。
</label>
:
End tag
<label for="chk-tos">我已……條款</label>
:<input>
、<hr>
、<img>
等。
<br>
:換行
空白鍵預設會重疊
:可疊加的「空白 character entity」
<!-- -->
:多行註解
<h1>
~<h6>
:標題。
<p>
:段落; <blockquote>
:引文。
<strong>
:重點;<em>
:強調。
<hr>
:分隔線。
<ol>
,<ul>
:有序/無序列表;<li>
:列表的項目。
<dl>
:定義列表; <dt>
:被定義的項目; <dd>
:定義。
<table>
表格(table);<tr>
表格列(table row);
<td>
資料格子(table data cell); <th>
表頭格子(table header)。
<tr>
裡只能裝 <td>
或 <th>
;<td>
裡啥都能裝。
<img>
圖,<a>
超連結,<iframe>
嵌入框
<img src="網址" alt="圖壞掉時顯示的字" (width="寬" height="高")>
<a href="網址" (target="_blank")>顯示的文字</a>
<iframe src="網址"></iframe>
<input type="text|file|submit|..." name="變數名字" value="值">
name
屬性一樣 → 同一組。
<label>
之 for
屬性和 <input>
之 id
屬性配對。
另外也可以用 <label>
包住 <input>
來配對。
<section>
:章節 / 小節
<article>
:一篇文章
兩者可以互包。
<nav>
:導覽選單
<header>
、<footer>
:文章段落或頁面的開頭、結尾
div
與 span
大部分 element 都有下面屬性
class
, id
:替該 element 加上一個 classname / unique ID,使 CSS 的 selector 能選取、Javascript 方便操作。title
:工具提示(tooltip)style
:加上 CSS Declaration。MDN HTML Elements 標籤列表、屬性介紹
請在右邊按 右鍵 → 「檢查元素」
每個 element 有自己的 permitted contents。
<p>
、<h1>
~<h6>
裡頭只能包 phrasing content。<ul>
、<ol>
裡面只能包 <li>
。<tr>
裡面只能包 <td>
與 <th>
。<div>
inside <p>
綜合前述,我們可以做出這樣的網頁內容:
但這並不是完整的網頁架構。
<!DOCTYPE html>
告訴瀏覽器用最新標準解析此網頁
<html>
包住 <head>
和 <body>
。<head>
存放「不是網頁內文」的其他資訊。
<title>
瀏覽器分頁標題<meta charset="utf-8">
設定網頁編碼<meta name="..." content="...">
其他設定<body>
網頁內容在 <head>
與 <head>
中間加上
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
參考資料:html5shiv 官方說明。
Boilerplate = 「樣板」
偵測 IE、瀏覽器支援度、標準化 CSS 等常用功能。