HTML5-新的表单控件

  • color:颜色选择

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        选择你喜欢的颜色: <input type="color" name="" id="" value="" placeholder="">
    </form>

</body>
</html

  • date:选择日期年月日,不包括时间

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        请选您的出生日期年月日:<input type="date" id="date" name="date">
    </form>

</body>
</html

​​​​​​​

  • datetime-local:允许用户选择特定的日期年月日和时间(UTC时间)datetime已废弃。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        请选择您的出生日期年月日和时间:<input type="datetime-local" id="datetime-local" name="datetime-local">
    </form>

</body>
</html

  • email:输入电子邮件地址,会自动验证格式是否正确

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        电子邮件:<input type="email" id="email" name="email">
    </form>

</body>
</html

  • month:选择月份和年份

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        请选择您的出生年月:<input type="month" id="month" name="month">
    </form>

</body>
</html

  • number:输入数字,可以设置最小值(min)和最大值(max

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        数字:<input type="number" id="number" name="number" min="1" max="10">
    </form>

</body>
</html

  • range:创建一个滑动条,允许用户在一定范围内选择一个值

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        <input type="range" id="range" name="range" min="0" max="10">
    </form>

</body>
</html

  • search:搜索域/搜索控件,与 text 类似,但语义上表明它用于搜索。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        搜索:<input type="search" id="search" name="search">
    </form>

</body>
</html

  •  tel:输入电话号码,浏览器不会验证电话号码的格式。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        电话:<input type="tel" id="tel" name="tel">
    </form>

</body>
</html

  • time:选择时间,小时和分钟

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        时间:小时和分钟:<input type="time" id="time" name="time">
    </form>

</body>
</html

  •  url:输入网址,会自动验证格式是否正确

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        请输入完整的网址:<input type="url" id="url" name="url">
    </form>

</body>
</html

  •  week:选择周,年月周

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>

    <form>
        <input type="week" id="week" name="week">
    </form>

</body>
</html

  • 8
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值