The table is a tag in XHTML that is in an awkward situation. This section is only available for understanding.
Before CSS became popular, tables were widely used in positioning. In XHTML, tables are not recommended for positioning, and W3C hopes that CSS can replace <table>'s position in positioning. However, in fact, because using CSS layout often requires a lot of handwritten code work (common web design software such as Dreamweaver cannot perfectly support the display of divs), <table> is still used by many websites to use homepage layout, such as Google's More products page uses tables for positioning. However, I personally recommend that you start using CSS to locate web pages, because this is the direction of web development. Of course, replacing tables with CSS in the early stages may cause you a lot of trouble.
In XHTML, the tag for creating a table is <table>. When writing code, we must first use the <tr> tag to divide the table into rows and rows, and then use the <td> tag to divide each row into grids and grids. Creating tables with complete handwritten code is very difficult and inefficient, and making tables in web page production software is as simple as Word, you only need to select simple attributes such as rows and columns. However, we may encounter the possibility that the automatically made tables do not meet the requirements and need to be adjusted in the code pattern. Therefore, we still need to understand the specific writing of XHTML table tags.
The <table> tag can have a border attribute. If the value of the border attribute is not set, by default, the browser will not display the border of the table.
Let's create a four row and two column label, the code is as follows:
| <table border=1> <tr> <td>A grid</td> <td>A grid</td> </tr> <tr> <td>A grid</td> <td>A grid</td> </tr> <tr> <td>A grid</td> <td>A grid</td> </tr> <tr> <td>A grid</td> <td>A grid</td> </tr> </table> |
The result is displayed as follows: Pay attention to the above code, there are 4 pairs of <tr>, corresponding to the following 4 lines. And without a <tr> (row), there are two <td> cells. So it becomes a 4 rows and 2 columns table.
| A grid | A grid |
| A grid | A grid |
| A grid | A grid |
| A grid | A grid |
Such tables are sufficient to list information such as data, but the tables used to locate are usually more complicated. Again, we do not recommend using table for positioning, so we will only briefly introduce <table> here.