几个不太常用但很有用的HTML Tag
2009-03-05 16:50
537 查看
虽然经常接触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"> red</label><br>
<input type="checkbox" name="color" id="color_g" value="green"><label for="color_g"> green</label><br>
<input type="checkbox" name="color" id="color_b" value="blue"><label for="color_x"> 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>
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"> red</label><br>
<input type="checkbox" name="color" id="color_g" value="green"><label for="color_g"> green</label><br>
<input type="checkbox" name="color" id="color_b" value="blue"><label for="color_x"> 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>
相关文章推荐
- 几个不太常用但很有用的HTML Tag
- 几个不太常用但很有用的HTML Tag
- 几个不太常用但很有用的HTML Tag
- 几个不太常用但很有用的HTML Tag
- 几个不太常用但很有用的HTML Tag
- 收藏: 几个不太常用但很有用的HTML Tag
- 几个不太常用的HTML Tag
- 几个不常用,但很有用的html标签
- 在SQL Server 的使用过程中,发现几个很有用,但不太常用
- 学习HTML标签(几个不常用但是很实用的标签)
- 几个不太常用的git命令
- 几个html常用取尺寸属性
- 几个不常用但很有用的javascript方法
- php的几个不太常用的函数
- html常用的几个重定向连接
- VBScript:Join 函数一个不太常用,却很有用的函数
- ASP常用的几个功能模块封装成函数调用(登录验证,状态切换。。) http://www.tsingfeng.com/archives/?article-89.html
- HTML:介绍几个不常用的HTML标签
- html/css实现居中的几个常用方法
- VS2010 几个不常用,却很有用的快捷键