In fact many people will say “I’ve seen that tables should never be used”, but this is absolutely wrong! This advice is only for using HTML tables to define the layout of your web page, but tables are perfect for conveniently arranging rows and columns of information, and if you absolutely must display tabular data on a page, you have to use them! why not? However, in this case, some people ignore the existence of certain HTML tags for tables and don’t know how to use them correctly. HTML has 10 table-related tags. Here is a list with a brief introduction, but first, the document should be properly defined in HTML 4.01/XHTML 1 or HTML 5:
A basic table structure is as follows: It contains a title, header, body, and footer. The correct order of HTML elements is:
You can also use <col> and <colgroup> to define table columns or group columns:
The following is an example of a correct table structure: Copy code The code is as follows:<table border="1"> <caption>Table caption here</caption> <colgroup span="1" style="background:#DEDEDE;"/> <colgroup span="2" style="background:#EFEFEF;"/> <!-- Table Header--> <thead> <tr> <th>Head 1</th> <th>Head 2</th> <th>Head 3</th> </tr> </thead> <!-- Table Footer--> <tfoot> <tr> <td>Foot 1</td> <td>Foot 2</td> <td>Foot 3</td> </tr> </tfoot> <!-- Table Body--> <tbody> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>D</td> <td>E</td> <td>F</td> </tr> </tbody> </table> The result in the browser is shown below: ![]() Some tips about tables
In order to achieve the currently advocated development model of separation of presentation and structure, Front-end Observation recommends that all presentation-related things on the page be controlled by CSS, instead of using HTML's own attributes to control the presentation of the page. Tables are the most easily overlooked ones. For more details about tables, see the W3C document: w3 Introduction to tables Finally, I leave you with a very simple question. Which CSS property is equivalent to the cellpadding property of the table? |
<<: Detailed explanation of mixed inheritance in Vue
>>: How to invert the implementation of a Bezier curve in CSS
OOM stands for "Out Of Memory", which m...
Table of contents DOMContentLoaded and load What ...
Preface This article was written by a big shot fr...
This article example shares the specific code of ...
1. Install and use Docer CE This article takes Ce...
I slept late yesterday and was awake the whole da...
a : Indicates the starting or destination positio...
This article uses an example to describe the inte...
Two-column layout is often used in projects. Ther...
Implementation of regular backup of Mysql databas...
There is no problem with the Dockerfile configura...
Table of contents 1. Embed CSS styles directly in...
Preface Due to the weak typing of JS, loose writi...
The reason is this I wanted to deploy a mocker pl...
Preface This article introduces the installation ...