Xhtml有很多不常用却很有用的标签。有的能事半功倍,有的能改进语义,有的则能提高易用性,我总结了一些,总结的原则是有用而且能用,就是大多数浏览器得支持,否则就不算“上上签”了。只能望“签”兴叹又有什么用呢?
作用:
属性:
Href:链接地址
target:目标,他的值可以是_blank,_parent,_self,_top,可以在除Strict模式下使用,这个用法我最先是在163.com上发现的。
用法:
<code class="html"><span class="tag"><head</span><span class="tag">></span><!—写在head标签之间--<span class="tag">> <br><span class="tag"><base</span><span class="aname"> href</span>=<span class="avalue">"http://www.qq.com/"</span> <span class="tag">/></span> <!—将默认链接定义为http://www.qq.com/--<span class="tag">> <br><span class="tag"><base</span><span class="aname"> target</span>=<span class="avalue">"_blank"</span> <span class="tag">/></span> <!—将默认链接目标定义为新窗口中打开--<span class="tag">> <br><span class="tag"></head></span></code><p><br><font size="4"><strong><caption>标签</strong></font><br> <strong>作用:</strong>caption标签用来定义表格的标题,给表格定义一个标题,来说明这个表格是干什么的,岂不是很有“语义”,caption应该写在table之后,默认的样式是居中显示在表格的顶部。你可以通过css来改变它的样式。<br> <strong>用法:</strong><br></p>
<code class="html"><span class="tag"><table</span><span class="aname"> width</span>=<span class="avalue">"200"</span><span class="aname"> border</span>=<span class="avalue">"1"</span> <span class="tag">></span> <br><span class="tag"><caption</span><span class="tag">></span> <span class="mlcom"><!--caption应该写在table之后--></span> <br>其实我是caption <br><span class="tag"></caption></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><td</span><span class="tag">></span><span class="entity"> </span><span class="tag"></td></span> <br><span class="tag"><td</span><span class="tag">></span><span class="entity"> </span><span class="tag"></td></span> <br><span class="tag"></tr></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><td</span><span class="tag">></span><span class="entity"> </span><span class="tag"></td></span> <br><span class="tag"><td</span><span class="tag">></span><span class="entity"> </span><span class="tag"></td></span> <br><span class="tag"></tr></span> <br><span class="tag"></table></span></code><p><br><font size="4"><strong><thead>标签、<tbody>标签、<tfoot>标签</strong></font><br> 作用:thead、tfoot 以及 tbody标签跟他们的名字那样,分别是表格的头部(很多人只是用th)、主题、和底部,他们能让表格更加语义化的同时,也能让我们更加方便的控制表格的表现。国外还有人用很变态地方法用这三个表其做出标题能跟随表格,或者tbody固定高度,多出的行数出现滚动条。有兴趣的可以搜素下或者是这做一下。<br>注意:<font color="#ff0000">如果您使用 thead、tfoot 以及 tbody 元素,您就必须使用全部的元素。它们的出现次序是:thead、tfoot、tbody,这样浏览器就可以在收到所有数据前呈现页脚了。</font><br> <strong>用法:</strong><br></p>
<code class="html"><span class="tag"><table</span><span class="aname"> border</span>=<span class="avalue">"1"</span><span class="tag">></span> <br><span class="tag"><thead</span><span class="tag">></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><th</span><span class="tag">></span>科目<span class="tag"></th></span> <br><span class="tag"><th</span><span class="tag">></span>分数<span class="tag"></th></span> <br><span class="tag"></tr></span> <br><span class="tag"></thead></span> <br><span class="tag"><tfoot</span><span class="tag">></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><td</span><span class="tag">></span>总分<span class="tag"></td></span> <br><span class="tag"><td</span><span class="tag">></span>159<span class="tag"></td></span> <br><span class="tag"></tr></span> <br><span class="tag"></tfoot></span> <br> <br><span class="tag"><tbody</span><span class="tag">></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><td</span><span class="tag">></span>语文<span class="tag"></td></span> <br><span class="tag"><td</span><span class="tag">></span>99<span class="tag"></td></span> <br><span class="tag"></tr></span> <br><span class="tag"><tr</span><span class="tag">></span> <br><span class="tag"><td</span><span class="tag">></span>数学<span class="tag"></td></span> <br><span class="tag"><td</span><span class="tag">></span>60<span class="tag"></td></span> <br><span class="tag"></tr></span> <br><span class="tag"></tbody></span> <br><span class="tag"></table></span></code><p><br><font size="4"><strong><fieldset>标签和<legend>标签</strong></font><br> <strong>作用:</strong><fieldset>元素用来分类表单中的元素,而<legend>则能给这个组定义一个标题。你一定见过类似下面domo的布局吧!他们也可以通过css定义样式。<br> <strong>用法:</strong><br></p>
<code class="html"><span class="tag"><form</span><span class="tag">></span> <br><span class="tag"><fieldset</span><span class="tag">></span> <br><span class="tag"><legend</span><span class="tag">></span>基本信息<span class="tag"></legend></span> <br>姓名: <span class="tag"><input</span><span class="aname"> type</span>=<span class="avalue">"text"</span> <span class="tag">/></span> <br>性别: <span class="tag"><input</span><span class="aname"> type</span>=<span class="avalue">"text"</span> <span class="tag">/></span> <br><span class="tag"></fieldset></span> <br><span class="tag"></form></span></code><p><br><font size="4"><strong><sub> 标签和<sup> 标签</strong></font><br> 作用:<sub> 标签和<sub> 标签分别是上标和下标,虽然他们在各个浏览器的表现不一样,你<br>同样可以使用css定义他们的样式。<br> <strong>用法:</strong><br></p>
<code class="html">2<span class="tag"><sup</span><span class="tag">></span>我是上标<span class="tag"></sup></span> <br>2<span class="tag"><sub</span><span class="tag">></span>我是下标<span class="tag"></sub></span></code><p><br><font size="4"><strong><label>标签</strong></font><br> <strong>作用:</strong>label 标签的使用可以扩大表单的点击区域来改进表单的易用性。看看下面的用法:点击文字的时候相当于点击了单选控件,这样用户体验是不是会更好一些?<br> <strong>用法:</strong><br></p>
<code class="html"><span class="tag"><form</span><span class="tag">></span> <br><span class="tag"><label</span><span class="aname"> for</span>=<span class="avalue">"nan"</span><span class="tag">></span>先生<span class="tag"></label></span> <br><span class="tag"><input</span><span class="aname"> type</span>=<span class="avalue">"radio"</span><span class="aname"> name</span>=<span class="avalue">"sex"</span><span class="aname"> id</span>=<span class="avalue">"nan"</span> <span class="tag">/></span> <br><span class="tag"><br</span> <span class="tag">/></span> <br><span class="tag"><label</span><span class="aname"> for</span>=<span class="avalue">"nv"</span><span class="tag">></span>女士<span class="tag"></label></span> <br><span class="tag"><input</span><span class="aname"> type</span>=<span class="avalue">"radio"</span><span class="aname"> name</span>=<span class="avalue">"sex"</span><span class="aname"> id</span>=<span class="avalue">"nv"</span> <span class="tag">/></span> <br><span class="tag"></form></span></code><br><font size="4"><strong><optgroup> 标签</strong></font><br> <strong>作用:</strong><option></option> 标签可以给select中的option进行分组,这在下拉项目很多的时候很有用,配合label标签给每组命名。你也可以像淘宝那样给每组用css定义不同的颜色。<br> <strong>用法:</strong><br>
<code class="html"><span class="tag"><select</span><span class="tag">></span> <br><span class="tag"><optgroup</span><span class="aname"> label</span>=<span class="avalue">"自驾游"</span><span class="tag">></span> <span class="mlcom"><!--配合label标签给每组命名--></span> <br><span class="tag"><option</span><span class="tag">></span>省内<span class="tag"></option></span> <br><span class="tag"><option</span><span class="tag">></span>省外<span class="tag"></option></span> <br><span class="tag"></optgroup></span> <br><span class="tag"><optgroup</span><span class="aname"> label</span>=<span class="avalue">"旅行社"</span><span class="tag">></span> <br><span class="tag"><option</span><span class="tag">></span>省内<span class="tag"></option></span> <br><span class="tag"><option</span><span class="tag">></span>省外<span class="tag"></option></span> <br><span class="tag"><option</span><span class="tag">></span>国外<span class="tag"></option></span> <br><span class="tag"></optgroup></span> <br><span class="tag"></select></span></code><br> 你如果对更多的xhtml标签感兴趣,可以考虑看一看《HTML和XHTML权威指南》这本书,你也能在网上找到电子版的。我看过英文影印版的,虽然是英文但也不是太难看懂。<br> 你要是知道其他很有用的标签告诉我们吧!