Web階段:第一章:HTML語言
font標(biāo)簽是字體標(biāo)簽
color是顏色屬性
size是大小屬性。值是1-7,1最小,7最大
face屬性設(shè)置文本的字體
需求1:在網(wǎng)頁(yè)上顯示 我是字體標(biāo)簽 ,并修改字體為 宋體,顏色為紅色。
舉例:
<font color="red" face="楷體" size="7">我是字體標(biāo)簽</font>
特殊字符
< 特殊字符 <
> 特殊字符 >
空格 特殊字符
html會(huì)把多個(gè)連續(xù)的空白字符,都會(huì)轉(zhuǎn)換成為一個(gè)空格來處理。
需求1:把<br> 換行標(biāo)簽 變成文本 轉(zhuǎn)換成字符顯示在頁(yè)面上
舉例:
我很<br>帥!<br/>
我很 帥!
標(biāo)題標(biāo)簽
h1 - h6 都是標(biāo)題標(biāo)簽
h1 最大
h6 最小
align 對(duì)齊屬性
left 左對(duì)齊(默認(rèn)值)
center 居中
right 右對(duì)齊
需求1:演示標(biāo)題1到 標(biāo)題6的
舉例:
<h1 align="left">標(biāo)題1</h1>
<h2 align="center">標(biāo)題2</h2>
<h3 align="right">標(biāo)題3</h3>
<h4>標(biāo)題4</h4>
<h5>標(biāo)題5</h5>
<h6>標(biāo)題6</h6>
a標(biāo)簽
超鏈接標(biāo)簽
href 屬性是連接跳轉(zhuǎn)的地址
target 屬性 設(shè)置哪個(gè)窗口進(jìn)行跳轉(zhuǎn)
_self 表示當(dāng)前窗口(默認(rèn)值)
_blank 打開一個(gè)新窗口去跳轉(zhuǎn)
舉例:
<a >百度</a><br/>
<a target="_self">百度_self</a><br/>
<a target="_blank">百度_blank</a><br/>
列表標(biāo)簽
ul 是無序列表
type屬性是每個(gè)列表項(xiàng)前面的符號(hào)
li 是列表項(xiàng)
需求1:使用無序,列表方式,把東北F4,劉能、趙四、宋小寶、小沈陽 ,展示出來
舉例:
<h1>東北F4</h1>
<ul type="none">
<li>劉能</li>
<li>趙四</li>
<li>宋小寶</li>
<li>小沈陽</li>
</ul>
img 標(biāo)簽
可以用來顯示圖片
src 設(shè)置你要顯示的圖片路徑
alt 當(dāng)設(shè)置的路徑找不到圖片的時(shí)候,用來代替顯示的文本
height 設(shè)置圖片的高度
width 設(shè)置圖片的寬度
border 設(shè)置圖片的邊框大小
JavaSE的路徑也分為相對(duì)路徑和絕對(duì)路徑兩種:
絕對(duì)路徑是: 盤符:\目錄\文件名
相對(duì)路徑: 從工程名開始算
web中的路徑:分為相對(duì)路徑和絕對(duì)路徑
相對(duì)路徑
. 表示當(dāng)前目錄
.. 表示上一級(jí)目錄
資源名 相當(dāng)于./資源名 (./ 可以省略)
絕對(duì)路徑
http://localhost:8080/imgs/10.jpg
http://ip:port/工程名/資源名
JavaSE的絕對(duì)路徑不能在html頁(yè)面中使用。
需求1:使用img標(biāo)簽顯示一張美女的照片。并修改寬高,和邊框?qū)傩?br>舉例:
<img alt="美女找不到" src="../imgs/1.jpg" height="120" width="100" border="1"/>
<img alt="美女找不到" src="2.jpg" height="120" width="100" border="1"/>
<img alt="美女找不到" src="../3.jpg" height="120" width="100" border="1"/>
<img alt="美女找不到" src="../imgs/4.jpg" height="120" width="100" border="1"/>
<img alt="美女找不到" src="../imgs/5.jpg" height="120" width="100" border="1"/>
<img alt="美女找不到" src="http://localhost:8080/imgs/10.jpg" height="120" width="100" border="1"/>
table表格
border是設(shè)置表格的邊框
width是設(shè)置表格的寬度
height是設(shè)置表格的高度
tr 是表格的行
td 是表格的單元格
align 是對(duì)齊 屬性
th 是表格的表頭(第一行標(biāo)題。默認(rèn)是居中,并加粗)
b 標(biāo)簽是加粗標(biāo)簽
center 讓被包含的內(nèi)容居中顯示
需求1:做一個(gè) 帶表頭的 ,三行,三列的表格,并顯示邊框
需求2:修改表格的寬度,高度,表格的對(duì)齊方式,單元格間距。
舉例:
<center>
<table border="1" width="200" height="200" cellspacing="0">
<tr>
<th>1.1</th>
<th>1.2</th>
<th>1.3</th>
</tr>
<tr>
<td>2.1</td>
<td>2.2</td>
<td>2.3</td>
</tr>
<tr>
<td>3.1</td>
<td>3.2</td>
<td>3.3</td>
</tr>
</table>
</center>
跨行跨列表格
colspan屬性設(shè)置單元格所占的列數(shù)
rowspan屬性設(shè)置單元格所占的行數(shù)
需求1:新建一個(gè)五行,五列的表格,第一行,第一列的單元格要跨兩列,第二行第一列的單元格跨兩行,第四行第四列的單元格跨兩行兩列。
舉例:
<table border="1" cellspacing="0" height="500" width="500">
<tr>
<td colspan="2">1.1</td>
<td>1.3</td>
<td>1.4</td>
<td>1.5</td>
</tr>
<tr>
<td rowspan="2">2.1</td>
<td>2.2</td>
<td>2.3</td>
<td>2.4</td>
<td>2.5</td>
</tr>
<tr>
<td>3.2</td>
<td>3.3</td>
<td>3.4</td>
<td>3.5</td>
</tr>
<tr>
<td>4.1</td>
<td>4.2</td>
<td>4.3</td>
<td colspan="2" rowspan="2">4.4</td>
</tr>
<tr>
<td>5.1</td>
<td>5.2</td>
<td>5.3</td>
</tr>
</table>
iframe框架標(biāo)簽 (內(nèi)嵌窗口)
iframe 標(biāo)簽 可以在一個(gè)頁(yè)面上,開一個(gè)窗口,單獨(dú)加載(顯示)一個(gè)頁(yè)面內(nèi)容
src 屬性設(shè)置 需要單獨(dú)顯示的哪個(gè)頁(yè)面的 地址(可以相對(duì)路徑,也可以是絕對(duì)路徑)
width 設(shè)置寬度
height 設(shè)置高度
iframe和a標(biāo)簽組合使用步驟:
1、給iframe標(biāo)簽設(shè)置name屬性。設(shè)置一個(gè)名稱
2、給a標(biāo)簽的target屬性設(shè)置需要跳轉(zhuǎn)的iframe的name屬性值
舉例:
<iframe src="./6.表格標(biāo)簽.html" width="500" height="300" name="bbj"></iframe>
<ul>
<li><a href="1.font標(biāo)簽.html" target="bbj">1.font標(biāo)簽.html</a></li>
<li><a href="2.特殊字符.html" target="bbj">2.特殊字符.html</a></li>
<li><a href="3.標(biāo)題標(biāo)簽.html" target="bbj">3.標(biāo)題標(biāo)簽.html</a></li>
<li><a href="5.img標(biāo)簽.html" target="bbj">5.img標(biāo)簽.html</a></li>
</ul>
表單標(biāo)簽
input type=text 表示一個(gè)普通文本輸入框 value屬性是文本框的默認(rèn)值
input type=password 表示一個(gè)密碼輸入框 value屬性是文本框的默認(rèn)值
input type=radio 表示一個(gè)單選框 name屬性可以對(duì)其進(jìn)行分組 checked="checked" 表示默認(rèn)選中
input type=checkbox 表單一個(gè)篩選框 checked="checked" 表示默認(rèn)選中
input type=submit 是提交按鈕 value屬性可以修改按鈕的文本
input type=reset 是重置按鈕 value屬性可以修改按鈕的文本 讓所有表單項(xiàng)都恢復(fù)默認(rèn)值
input type=button 是按鈕 value屬性可以設(shè)置按鈕的文本
input type=file 是文件上傳域
input type=hidden 是隱藏域。當(dāng)我們需要給服務(wù)器發(fā)送一些信息,而這些信息,不希望用戶看到。這個(gè)時(shí)候就可以使用隱藏域。
select 是下拉列表框
option 是下拉列表中的選項(xiàng) selected="selected"表示默認(rèn)選中
textarea 表示多行文本輸入框 起始標(biāo)簽和結(jié)束標(biāo)簽中的內(nèi)容就是默認(rèn)值
rows 設(shè)置顯示幾行
cols 設(shè)置每行幾個(gè)字
舉例:
<form action="">
用戶名:<input type="text"><br/>
密碼:<input type="password" /><br/>
確認(rèn)密碼:<input type="password" /><br/>
選擇性別:<input name="sex" type="radio" />男<input name="sex" type="radio" />女<br/>
選擇興趣愛好:
<input type="checkbox" />喝酒
<input type="checkbox" />抽煙
<input type="checkbox" />燙頭<br/>
選擇國(guó)籍:
<select>
<option>中國(guó)</option>
<option>美國(guó)</option>
<option>日本</option>
</select><br/>
自我評(píng)價(jià):<textarea rows="10" cols="20"></textarea><br/>
<input type="submit" value="注冊(cè)"/>
<input type="reset"/>
</form>
表單格式化
在表單里加上table表格
舉例:
<center>
<h1>注冊(cè)用戶</h1>
<form action="">
<table>
<tr>
<td>用戶名:</td>
<td><input type="text"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" /></td>
</tr>
<tr>
<td>確認(rèn)密碼:</td>
<td><input type="password" /></td>
</tr>
<tr>
<td>選擇性別:</td>
<td>
<input name="sex" type="radio" />男
<input name="sex" type="radio" />女
</td>
</tr>
<tr>
<td>興趣愛好:</td>
<td>
<input type="checkbox" />喝酒
<input type="checkbox" />抽煙
<input type="checkbox" />燙頭
</td>
</tr>
<tr>
<td>選擇國(guó)籍:</td>
<td>
<select>
<option>中國(guó)</option>
<option>美國(guó)</option>
<option>小日本</option>
</select>
</td>
</tr>
<tr>
<td>自我評(píng)價(jià):</td>
<td>
<textarea rows="10" cols="20"></textarea>
</td>
</tr>
<tr>
<td><input type="submit" value="注冊(cè)"/></td>
<td><input type="reset"/></td>
</tr>
</table>
</form>
</center>
表單提交的細(xì)節(jié)
form 是表單
action 表單提交的服務(wù)器地址
method 請(qǐng)求的方式 GET或POST
當(dāng)我們提交表單的時(shí)候。如果表單項(xiàng)的數(shù)據(jù)沒有發(fā)送給服務(wù)器
1、表單項(xiàng)必須要有name屬性,沒有name屬性在提交表單的時(shí)候。數(shù)據(jù)不會(huì)發(fā)給服務(wù)器。
2、單選、復(fù)選框、(下拉列表項(xiàng)可選)。都要添加value屬性。否則只會(huì)提交給服務(wù)器on值
3、表單提交的時(shí)候。如果表單項(xiàng)不在提交的表單內(nèi),也不會(huì)把數(shù)據(jù)發(fā)給服務(wù)器。
GET請(qǐng)求和POST請(qǐng)求的區(qū)別
GET請(qǐng)求的特點(diǎn):
1、瀏覽器地址欄中是action屬性值+?+請(qǐng)求參數(shù)(表單信息)例如: http://localhost:8080/?action=add&username=wzg168&password=123456&sex=boy&hobby=hj&country=cn&desc=1234
2、不安全
3、請(qǐng)求數(shù)據(jù)的長(zhǎng)度限制
POST請(qǐng)求的特點(diǎn):
1、瀏覽器地址欄只有action的屬性值
2、相對(duì)安全
3、數(shù)據(jù)沒有長(zhǎng)度限制
div、span、p標(biāo)簽
div :div標(biāo)簽(塊標(biāo)簽) 默認(rèn)獨(dú)占一行
span :是內(nèi)聯(lián)標(biāo)簽 默認(rèn)寬度就是封裝的數(shù)據(jù)的長(zhǎng)度
p :是段落標(biāo)簽 默認(rèn)會(huì)在段落的上方或下方各空出一行來
需求1:div、span、p標(biāo)簽的演示
<div>這是div塊標(biāo)簽1</div>
<div>這是div塊標(biāo)簽2</div>
<span>span標(biāo)簽1</span>
<span>span標(biāo)簽2</span>
<p>段落1</p>
<p>段落2</p>