This article shares with you a summary of the different table attributes of HTML (with code). The content is very good. Friends in need can refer to it. I hope it can help everyone.
Here we mainly summarize and record some attributes and simple styles of the table for future convenience.
1.
Used to define the table of HTML, with local attributesborderrepresents the border, and the value of the border attribute must be 1 or the empty string (""). This attribute does not control the style of the border, but is controlled by CSS
The table element can have tr, th, td, thead, tbody, tfoot, colgroup elements
2,
Used to define a row of the table. Since HTML tables are row-oriented, each row must be represented separately
The tr element can be used within the table, thead, tbody and tfoot elements
The tr element can contain one or more td Or th element
Its align, bgcolor and other attributes are obsolete. If you want to set attributes, please use CSS settings
3,
Used to define the header of the table and the wrapper of the table header. You can define one or more rows, which are column labels of the table element
Without thead element, all tr are assumed to belong to the body of the table
6,Used to define the body of the table
7,Used to define the footer of the marked table
⚠️:
Used to define table cells, can be used with colspan, rowspan, headers local attributes (1)colspan: column span, this attribute specifies the columns that the cell can span Number, the value of this attribute must be an integer (2) rowspan: row span, this attribute specifies the number of rows that the cell can span, the value of this attribute must be an integer ( 3) headers: The value of this attribute is the ID attribute value of one or more cells, which associates the cells with column headers and can be used with screen readers ⚠️:Each The table must contain the above three elements A simple example
Copy after login
The effect is as follows: 4. |
Used to define the title cell so that we can effectively distinguish the data and its description It The same local attributes as the <td>element have the following differences:
|
is the header Marker, usually located in the first row or column. Moreover, the text in | will be bolded by default, but | will not. | is a data mark, indicating the specific data of the cell.## 5. | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Used to define table column groups, which can be used to apply styles to a certain column. Of course, you can also use the following The col element
has the local attribute span
indicating the number of columns that the column group should span. The default is one column, that is, setting the style for one column of the table can contain one or more elements9,Used to represent a single column of the table, it is recommended to use
to wrap the element instead of to directly set the span attribute to define the group also has a local Attribute span is placed inside the element of , and the instance of represents a column in the group. Use this tag to apply styles to a group of columns and a single column of the group10,Rank | Name | Color | Size & Votes | |
---|---|---|---|---|
Rank Footer | Name Footer | Color Footer | Size And Votes Footer | |
Favorite: | XML | CSS | Java | IOS |
2nd Favorite: | Web | HTML5 | CS | 460 |
The effect is as follows:
Related recommendations:
Introduction to how to dynamically generate html elements and add attributes to elements (with code)
The above is the detailed content of Summary of different table attributes of HTML (with code). For more information, please follow other related articles on the PHP Chinese website!