• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

几个不太常用但很有用的HTML Tag

发布: 2007-7-04 13:34 | 作者: admin | 来源:  网友评论 | 查看: 12次 | 进入软件测试论坛讨论

领测软件测试网

(转)
虽然经常接触HTML,不过有些标签以前却从没引起我的注意。但是其中几个Tag的确比较有用,而且是符合W3C XHTML标准的。

1. Label

Label是用来标记Input元素的提示的。例如:

<label for="id_name">Name</label><br />
<input type="text" name="name" id="id_name" size="20"/>


Label的“For”属性要和Input元素的ID相一致。

好处:点击提示文字,就自动Focus对应的输入元素。对于Radio,Checkbox这类点击区域特别小的控件特别有用:
Color:<br />
<input type="checkbox"  name="color" id="color_r" value="red"><label for="color_r">&nbsp;red</label><br>
<input type="checkbox"  name="color" id="color_g" value="green"><label for="color_g">&nbsp;green</label><br>
<input type="checkbox"  name="color" id="color_b" value="blue"><label for="color_x">&nbsp;blue</label><br><!--如果For和ID不匹配,点击文字是没有用的-->

 red
 green
 blue
 

2. FieldSet & Legend

FieldSet用来明确把一组Input控件归成一组(相当于VB/VC里面的Group控件),而Legend则是组的标题(相当于Group控件的标题)。 例如:

<fieldset style="width:20%">
  <legend>Person</legend>
  <label for="name">Name</label><input type="text" id="name" />
  <fieldset>
    <legend>Gender</legend>
    <input type="radio" name="gender" id="male" /><label for="male">Male</label><br>
    <input type="radio" name="gender" id="female" /><label for="female">Female</label>
  </fieldset>
</fieldset>
PersonName GenderMale
Female

3. Optgroup

用于Select里面的option的分组。例如:

<select name="age">
  <optgroup label="baby">
    <option>0-2</option>
    <option>3-5</option>
  </optgroup>
  <optgroup label="kid">
    <option>6-10</option>
    <option>10-15</option>
  </optgroup>
  <optgroup label="adult">
    <option>16-30</option>
    <option>31-40</option>
    <option>41-60</option>
  </optgroup>
</select>

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网