本节要解决的问题
form、input、select、textarea 的基本用法。
核心要点
- form 的 action 决定提交地址
- method 常用 get 或 post
- label 用 for 关联控件提升可用性
<form action="/login" method="post">\n <label for="u">用户名</label>\n <input id="u" name="username" required>\n <button type="submit">登录</button>\n</form>每个 input 都要有 name,否则提交后拿不到值。
本文根据 W3School HTML 教程 的知识点重新整理、补充示例编写,非原文转载。