美文网首页
HTML 表单的用法

HTML 表单的用法

作者: Chy18 | 来源:发表于2017-02-17 23:58 被阅读0次

    概念

    HTML 表单用于搜集不同类型的用户输入。

    HTML 表单元素

    1. ** <input> 元素**
      最重要的表单元素是 <input> 元素。
      <input> 元素根据不同的 type 属性,可以变化为多种形态。
      1-1.输入类型:text
      <input type="text"> 定义供文本输入的单行输入字段。
      <input type="text" name="lastname">
      1-2.输入类型:password
      <input type="password"> 定义密码字段。
      <input type="password" name="psw">
      1-3.Input Type: radio
      <input type="radio"> 定义单选框。
      <form> <input type="radio" name="sex" value="male" >Male <input type="radio" name="sex" value="female">Female </form>
      1-4.Input Type: checkbox
      <input type="checkbox"> 定义复选框。
      <form> <input type="checkbox" name="vehicle" value="Bike">I have a bike <input type="checkbox" name="vehicle" value="Car">I have a car </form>

    2. <select> 元素
      <select> 元素定义下拉列表。
      <option> 元素定义待选择的选项。列表通常会把首个选项显示为被选选项。但能够通过添加 selected 属性来定义预定义选项。

    <select> <option value="">1</option> <option value="" selected>2</option> </select>

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

    <textarea rows="行数" cols="列数"> 文本 </textarea>

    1. <button> 元素
      <button> 元素定义可点击的按钮。

    相关文章

      网友评论

          本文标题:HTML 表单的用法

          本文链接:https://www.haomeiwen.com/subject/xecrwttx.html