The role of table elements: used to format the display of data.
I. Basic structure of the table
Basic syntax for tables:
<table border= "Set table border size" width= "cellpadding=" "cellspaning=" ">
<TR align= "Alignment" >
<TD align= "" >
Cell contents
</TD>
......
</TR>
......
</TABLE>
<table></table>: Defining tables
<tr></tr>: Defining rows
<td></td>: Defining columns
Example:
Main properties:
border: The width of the border, in pixels (the default value is 0)
Widths: The width of the table, which can be expressed as a percentage (indicating that the table is the width of the parent tag), or an absolute value
CellPadding: The gap between cell contents and cells
CellSpacing: The gap between cells and cells
Align: Alignment with values of "center", "right" and "left"
colspan: Horizontal extrusion cell with a positive integer value representing the number of cells that this cell extends horizontally
RowSpan: Extends the cell vertically, and the value is a positive integer that represents the number of cells that the cell extends vertically.
<caption> caption for table: The caption element must be included in the table element and must be centered immediately after the <table> start tag.
Grammar
Start tag: Must
Content: in-line tagging
End tag: Required
Main properties:
Align attribute: Used to determine the position of the caption, there can be five kinds of values
Bottom, center, Laft, right, top
Second, form beautification
1. Set the size and border of the table
Width: Used to set table widths
Height: Used to set Table heights
border: Used to set the table border size
BorderColor: Used to set the table border color
<table width= "height=" "border=" bordercolor= "Red" >
<tr>
<TD colspan= "4" align= "Center" > Brand Mall </td>
</tr>
<tr>
<TD colspan= "2" > Laptop </td>
<TD colspan= "2" > Office Setup, stationery, consumables </td>
</tr>
<tr>
<td> HP </td>
<td> Asus </td>
<td> Printers </td>
<td> Burning Discs </td>
</tr>
</table>
Example:
2. Set background image and back color
Background: Property used to set the background picture of a table
BgColor: property is used to set the background color of tables, rows, and columns. "#EBEFFF" is a color value expressed in RGB, RGB refers to the red and green blue
<table width= "height=" border= "2" background= "Images\img.jpg" >
<tr>
<TD colspan= "6" > </td>
</tr>
<tr>
<TD colspan= "3" > Laptop </td>
<TD colspan= "3" bgcolor= "yellow" > Office equipment, stationery, consumables </td>
</tr>
<tr>
<td>IBM</td>
<td> HP </td>
<td> Asus </td>
<td> Printers </td>
<td> Burning Discs </td>
<td> Cartridges </td>
</tr>
</table>
Example:
3. Setting the Alignment
Align: property is used to set the alignment of tables, rows, and columns.
There are three kinds of values
Left: right-aligned default
Right: Align
Center: Center Alignment
Example:
4. Padding Properties and Spacing properties
cellpadding: Cell padding, used to set the padding distance within a table, indicating the thickness of each cell, the larger the value, the greater the cell content distance from the cell
cellspacing: Cell spacing, used to set the width of a table's inner box, representing the distance between two cells. The larger the value, the greater the distance between the cell and the cell
Fill Properties and Spacing properties:
<body>
<table border= "cellpadding=" "cellspacing=" bordercolor= "Red" >
<TR bordercolor= "Green" >
<TD colspan= "4" > Brand Mall </td>
</tr>
<tr>
<TD colspan= "2" > Laptop </td>
<TD colspan= "2" > Office equipment, stationery, consumables </td>
</tr>
<tr>
<td> HP </td>
<td> Asus </td>
<td> Printers </td>
<td> Burning Discs </td>
</tr>
</table>
</body>
Example:
Example of setting a fill property for a table:
5. Set up a cross-row, cross-column table
colspan: Horizontal extrusion cell with a positive integer value representing the number of cells that this cell extends horizontally
RowSpan: Extends the cell vertically, and the value is a positive integer that represents the number of cells that the cell extends vertically.
To set up a table across multiple columns:
To set up a table across multiple lines:
To set up a table that spans multiple rows and columns:
HTML (ii): Table elements