網頁
HTML
Learn More →
<b>
粗體字<strong>
粗體字,和 <b>
大同小異<i>
斜體字<em>
斜體字,和<i>
大同小異<small>
小字<sup>
上標<sub>
下標<ins>
底線<del>
<mark>
螢光筆(黃色)<br/>
換行<pre>
維持文字的段落和格式<code>
程式碼printf("Hello HTML!")
<kbd>
鍵盤輸入<samp>
電腦輸出<var>
變數<abbr>
首字母縮寫(+title),但沒啥用處(?<address>
地址<bdo>
句子方向,rtl從右到左,ltr從左到右<blockquote>
從別的網站引用文章<q>
引言,雙引號style="background-color:#F0F8FF;"
更換背景顏色
style="color:Tomato;"
更換文字顏色
style="border:2px solid Tomato;"
更換邊框顏色、寬度
style="text-align:center;"
規定文本的對齊方式,center置中
<!-- 註解寫在這裡 -->
點這裡就有已經整理好的140種顏色,需要再查就好
符號實在太多了,就不全部放上來了,這邊只貼連結,需要再找
如果想使用表情符號,請宣告<meta charset="UTF-8">
數學運算子
貨幣符號
箭頭符號
表情符號
各種圖示
<a>
加入連結href
定義網址target="_blank"
設定開啟模式
<head>
<style>
a:link
{
background-color: #008B8B;
color: white;
padding: 20px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:visited
{
background-color: #FFD700;
color: white;
}
a:hover, a:active
{
background-color: #20B2AA;
}
</style>
</head>
<a href="#C4">
傳送至書籤"#C4"<h2 id="C4">
設定書籤"#C4"<img src="https://i.imgur.com/sxUS3aI.jpg" alt="Ocean">
<img src="https://i.imgur.com/sxUS3aI.jpg" usemap="Ocean">
讓圖片成為地圖
<map name="Ocean"></map>
定義對應名稱地圖
<area shape="rect">
感應區域
rect - 正方形
circle - 圓形
poly - 多邊形
default - 整個區域
<area coords="10,10,50,30">
區域座標
<img src=" " align="bottom">
圖片在文字中對齊方式
bottom-底部
middle-置中
top-頂
寫在head的style中
background-image: url('ocean.jpg');
背景圖片background-repeat: no-repeat;
圖片是否重複?background-attachment: fixed;
圖片比例是否固定?background-size: 100%;
圖片大小
<head>
<style>
body
{
background-image:url('https://i.imgur.com/JF9XBpB.jpg');
background-repeat: no-repeat;
background-attachment: nfixed;
background-size: 100% 500%;
}
</style>
</head>
<table>
定義一個表格<th>
定義表格第一欄<tr>
換列<td>
換行<caption>
定義表格標題
<table>
<tr>
<th>飲料</th>
<th>金額</th>
</tr>
<tr>
<td>紅茶</td>
<td>20</td>
</tr>
<tr>
<td>綠茶</td>
<td>20</td>
</tr>
<tr>
<td>奶茶</td>
<td>30</td>
</tr>
</table>
飲料 | 金額 |
---|---|
紅茶 | 20 |
綠茶 | 20 |
奶茶 | 30 |
border-collapse
界線是否留白?text-align
文字位置border-spacing
邊界是否留白?colspan
合併欄rowspan
合併列id
辨識編號<li>
一項
<ul>
無編碼清單
<ol>
有編碼清單
<dl>
描述清單
<dt>
<dd>
type=" "
有編碼風格start="50"
設定起始點,從50開始數float:left
橫向清單display:block
留上下空間<div>
區塊(block-level),用於一開始設定,可容納多元素
<span>
區塊(inline),用於段落內、<h><p>
中
Example
<div style="background-color:black; color:white; padding:20px;">
<h2>London</h2>
<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div>
London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.
可編寫多個Classes,並合併使用,類似JAVA多重繼承的概念
<div classes="XXX">
<span classes"EEE">
metadata放在head底下,網站上前台是看不到的!
<head>
元素都要包在這個裡面<style>
常用<meta>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<base>
<link>
<script>
<form>
建立表單
<input>
輸入
<input type="OOO"> OOO為輸入元件
"text"
文字框"radio"
單選欄"submit"
有點像按鈕"checkbox"
勾選"color"
選顏色"password"
密碼"time"
時間"month"
月"week"
周"date"
天"datetime-local"
日期+時間"file"
檔案"tel"
電話號碼"url"
連結"reset"
回歸預設值<select>
下拉式選單
<option value="OOO">
選項
size="3" 高度
multiple 多選
<textarea>
文字框(多行)
<fieldset>
表單外框
<legend>
表單名稱
<datalist>
資料搜尋欄
必須放在form裡面,前須加上<input list="OOO">
<output>
輸出
oninput="x.value=parseInt(a.value)+parseInt(b.value)"
在form裡面宣告
<input type="range" id="a" name="a" value="50">
滑條
<input type="number" id="b" name="b" value="50">
數字調整欄
HTML5僅支援MP4, WebM, Ogg video檔案
影片推薦使用MP4
音樂推薦使用MP3
<video>
<source src="movie.mp4" type="video/mp4">
片源:movie.mp4
檔案類型必須是MP4
controls
手動播放、暫停、調整音量autoplay
自動撥放<audio>
<source src="music.mp3" type="audio/mp3">
片源:music.mp3
檔案類型必須是MP3
- controls
手動播放、暫停、調整音量
<iframe width="420" height="315"
src="https://www.youtube.com/watch?v=mpDldu2VUDU" alt="no">
</iframe>
<svg width=”100” height=”100”>
類似畫布(定義長&寬)
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow">
畫圓
cx - 圓中心的X座標
cy - 圓中心的Y座標
r - 圓的半徑
strock - 外框顏色
strock-width - 外框粗度
fill - 填滿顏色
<rect width="400" height="100" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)">
畫長方形
width:寬
height:高
rx:圓角
ry:圓角
<defs> <linearGradient id="OOO" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" /> <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" /> </linearGradient> </defs>
畫漸層
fill="url(#OOO)"
呼叫漸層
window.localStorage
瀏覽器關了以後,資料不會消失window.sessionStorage
瀏覽器關了以後,資料會消失
localStorage.setItem("標籤","儲存值")
存入資料,輸入對應的標籤和資料localStorage.removeItem("標籤")
刪除暫存的資料