课程进度 7% · 第2/20章第2/20章 · 标签 1/3
— 1 —
表单基础
HTML表单用于收集用户输入,是网页交互的核心。表单通过<form>标签定义,常配合input、textarea、button等控件。
html
1
<form action="/submit" method="post">
2
<input type="text" name="username" placeholder="用户名" />
3
<input type="password" name="password" placeholder="密码" />
4
<button type="submit">登录</button>
5
</form>
— 2 —
常用表单控件
- <input type="text">:单行文本。
- <input type="password">:密码框。
- <input type="email">:邮箱输入。
- <input type="number">:数字输入。
- <input type="checkbox">:复选框。
- <input type="radio">:单选框。
- <input type="file">:文件上传。
- <textarea>:多行文本。
- <select>:下拉菜单。
html
1
<form>
2
<input type="text" placeholder="姓名" />
3
<input type="email" placeholder="邮箱" />
4
<input type="checkbox" name="agree" />同意协议
5
<select name="city">
6
<option value="beijing">北京</option>
7
<option value="shanghai">上海</option>
8
</select>
9
<textarea placeholder="留言"></textarea>
10
<button type="submit">提交</button>
11
</form>
forminputtextareaselect控件