HTML中表单元素有哪些

这篇文章将为大家详细讲解有关HTML中表单元素有哪些,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

<input> 元素

最重要的表单元素是 <input> 元素。

<input> 元素根据不同的 type 属性,可以变化为多种形态。

<select> 元素(下拉列表)(推荐学习:HTML入门教程)

<select> 元素定义下拉列表:

实例

<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> 元素定义待选择的选项。

列表通常会把首个选项显示为被选选项。

您能够通过添加 selected 属性来定义预定义选项。

实例

<option value="fiat" selected>Fiat</option>

<textarea> 元素

<textarea> 元素定义多行输入字段(文本域):

实例

<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> 元素定义可点击的按钮:

实例

<button type="button" onclick="alert('Hello World!')">Click Me!</button>

关于HTML中表单元素有哪些就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。