3.表格、表单

本文介绍了HTML中的表格和表单元素,包括<table>标签的使用,<form>标签的结构,以及各种输入控件如<td>,<input>,<select>等的属性和用法。
摘要由CSDN通过智能技术生成

1.首先表格

写表格一定要先写<table></table>
里边可以加boder,表格边框粗细<table boder="1"></table>
<tr表示行><td表示列>

<colspan>占多少横着格子

<rowspan>是多少列格子

<table border="1">
<caption>购物车</caption><!--表格标题-->
  <tr>
    <td colspan="2" align="center">1-1</td>
    <td rowspan="2">1-3</td><td rowspan="3">1-4</td>
  </tr>
  <tr>
    <td>2-1</td><td>2-2</td>
  </tr>
  <tr>
    <td colspan="3" align="center">3-1</td>
  </tr>
</table>

2.表单

表单是<form action="提交路径"><form>
action表示提交路径

<form action="http://www.baidu.com">
  <!--name属性是所有控件必须添加的属性, 如果不添加则不传递此控件的内容
  maxlength最大字符长度 value设置默认值 readonly只读
  placeholder占位文本-->
  用户名:<input type="text" name="username" maxlength="5"
             value="tom" readonly
             placeholder="请输入用户名"><br>
  密码:<input type="password" name="password"
            placeholder="请输入密码" ><br>
  <!--checked设置默认选中 单选框必须设置value 否则提交on-->
  性别:<input type="radio" name="gender" value="m" id="r1">
  <label for="r1">男</label>
  <input type="radio" name="gender" checked value="w" id="r2">
  <label for="r2">女</label><br>
  <!--多选框和单选的属性通用-->
  兴趣爱好:<input type="checkbox" name="hobby" value="cy">抽烟
  <input type="checkbox" name="hobby" value="hj" checked>喝酒
  <input type="checkbox" name="hobby" value="tt">烫头<br>
  生日:<input type="date" name="birthday"><br>
  靓照:<input type="file" name="pic"><br>
  所在地:
  <select name="city">
    <option>北京</option>
    <option selected>上海</option>
    <option value="gz">广州</option>
  </select><br>

  <input type="submit" value="注册">
  <input type="reset">
  <input type="button" value="自定义按钮">
  <hr>
  <button type="submit">注册</button>
  <button type="reset">重置</button>
  <button type="button">自定义按钮</button>
</form>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值