Several common ways to use HTML tags

Source: Internet
Author: User

XHTML has many tags that are not often used but are useful. Some can improve the semantics of some, some can improve the ease of use, I summed up some, summed up the principle is useful and can be used, is the majority of browsers support, otherwise it is not "on the sign". Can only hope "sign" sigh what use?





<base> Label





function: The label specifies the default link address or link target for all links in the page. Sometimes we need to let the first page of the link all open in a new window, use this tag can be done!





attribute: href: Link address, Target: destination, his value can be _blank,_parent,_self,_top and can be used in addition to strict mode, which I first found on 163.com.





Usage:








<head><!--written between head tags-->


<base href= "http://www.3lian.com/"/> <!--define the default link as http://www.3lian.com/-->


<base target= "_blank"/> <!--define the default link target as a new window open-->


</head>


<head><!--written between head tags-->


<base href= "http://www.3lian.com/"/> <!--define the default link as http://www.3lian.com/-->


<base target= "_blank"/> <!--define the default link target as a new window open-->


</head>





<caption> Label





Role: Caption tags used to define the title of the table, to define a title to the table, to explain what the table is doing, it is not very "semantic", caption should be written after the table, the default style is centered on the top of the table. You can use CSS to change its style.





Usage:








<table width= border= "1" >


<caption> <!--caption should be written after the table-->


Actually, I'm caption
.

</caption>


<tr>


<td> </td>


<td> </td>


</tr>


<tr>


<td> </td>


<td> </td>


</tr>


</table>


<table width= border= "1" >


<caption> <!--caption should be written after the table-->


Actually, I'm caption
.

</caption>


<tr>


<td> </td>


<td> </td>


</tr>


<tr>


<td> </td>


<td> </td>


</tr>


</table>





<thead> tags, <tbody> tags, <tfoot> tags





role: THEAD, TFOOT, and tbody tags are the same as their names, the head of the table (many people just use th), theme, and bottom, they can make the table more semantic, but also make it easier for us to control the performance of the table. There are some people in foreign countries using these three tables to make the title can follow the table, or tbody fixed height, the number of rows appear scroll bar. Interested can search the vegetarian or this to do a bit.





Note: If you use THEAD, TFOOT, and tbody elements, you must use all the elements. They appear in the following order: THEAD, TFOOT, tbody, so that the browser can render the footer before all the data is received.





Usage:








<table border= "1" >


<thead>


<tr>


<th> Subjects </th>


<th> score </th>


</tr>


</thead>


<tfoot>


<tr>


<td> Total Score </td>


<td>159</td>


</tr>


</tfoot>


 


<tbody>


<tr>


<td> Languages </td>


<td>99</td>


</tr>


<tr>


<td> Mathematics </td>


<td>60</td>


</tr>


</tbody>


</table>


<table border= "1" >


<thead>


<tr>


<th> Subjects </th>


<th> score </th>


</tr>


</thead>


<tfoot>


<tr>


<td> Total Score </td>


<td>159</td>


</tr>


</tfoot>





<tbody>


<tr>


<td> Languages </td>


<td>99</td>


</tr>


<tr>


<td> Mathematics </td>


<td>60</td>


</tr>


</tbody>


</table>





<fieldset> label and <legend> label




The
action:<fieldset> element is used to classify elements in a form, while <legend> defines a title for the group. You must have seen a layout like the one below Domo! They can also define styles through CSS.





Usage:








<form>


<fieldset>


<legend> basic Information </legend>


Name: <input type= "text"/>


Sex: <input type= "text"/>


</fieldset>


</form>


<form>


<fieldset>


<legend> basic Information </legend>


Name: <input type= "text"/>


Sex: <input type= "text"/>


</fieldset>


</form>





<sub> label and <sup> label





:<sub> tags and <sup> tags are superscript and subscript, although they do not behave the same in different browsers, you can also use CSS to define their style.





Usage:








2<sup>, I'm superscript </sup>
.

2<sub> I am subscript </sub>


 





<label> Label





function: Label labels can be used to enlarge the click area of the form to improve the usability of the form. Look at the following usage: Clicking on the text is equivalent to clicking on the radio control so that the user experience is better?





Usage:








<form>


<label for= "Nan" > Mr. </label>


<input type= "Radio" name= "Sex" id= "nan"/>


<br/>


<label for= "NV" > Ms. </label>


<input type= "Radio" name= "Sex" id= "NV"/>


</form>


<form>


<label for= "Nan" > Mr. </label>


<input type= "Radio" name= "Sex" id= "nan"/>


<br/>


<label for= "NV" > Ms. </label>


<input type= "Radio" name= "Sex" id= "NV"/>


</form>





<optgroup> Label





: Tags can be used to group option in Select, which is useful in many Drop-down items, with label labels for each group. You can also use CSS to define different colors for each group, like Taobao.





Usage:





 





<select>


<optgroup label= "self-driving Tour" > <!--with label label for each group named-->


<option> Province </option>


<option> outside </option>


</optgroup>


<optgroup label= "travel Agency" >


<option> Province </option>


<option> outside </option>


<option> Foreign </option>


</optgroup>


</select>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.