<input> 元素
最重要的表單元素是 <input> 元素。
<input> 元素根據(jù)不同的 type 屬性,可以變化為多種形態(tài)。
<select> 元素(下拉列表)(推薦學(xué)習(xí):HTML入門教程)
<select> 元素定義下拉列表:
實(shí)例
<select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select>
<option> 元素定義待選擇的選項(xiàng)。
列表通常會(huì)把首個(gè)選項(xiàng)顯示為被選選項(xiàng)。
您能夠通過添加 selected 屬性來定義預(yù)定義選項(xiàng)。
實(shí)例
<option value="fiat" selected>Fiat</option>
<textarea> 元素
<textarea> 元素定義多行輸入字段(文本域):
實(shí)例
<textarea name="message" rows="10" cols="30"> The cat was playing in the garden. </textarea>
以上 HTML 代碼在瀏覽器中顯示為:
The cat was playing in the garden.
<button> 元素
<button> 元素定義可點(diǎn)擊的按鈕:
實(shí)例
<button type="button" onclick="alert('Hello World!')">Click Me!</button>