HTML <td> ɗaɗi
- Previous page <tbody>
- Next page <template>
تعريف وطرق الاستخدام
<td>
تعريف العنصر يعين خلية البيانات المعيارية في جدول HTML.
يوجد نوعان من الخلايا في جدول HTML:
- خلية العنوان - تحتوي على معلومات العنوان (استخدام <th> إنشاء العنصر)
- خلية البيانات - تحتوي على بيانات (استخدام
<td>
إنشاء العنصر)
افتراضيًا،<td>
النص في العنصر عادي، ومركزًا يسارًا.
النص في علامة <th> مكتوب بشكل افتراضي بسمك ثقيل ومركز.
يرجى الرجوع أيضًا إلى:
دليل HTML:HTML ɗaɗi
دليل مرجع DOM HTML:مفهوم TableData
دليل CSS:إعداد نمط الجدول
مثال
مثال 1
جداول HTML بسيطة، تحتوي على صفين وأربع خلايا جدول:
<table> <tr> <td>خلية A</td> <td>خلية B</td> </tr> <tr> <td>خلية C</td> <td>خلية D</td> </tr> </table>
مثال 2
كيفية التوجيه <td>
中的内容(使用 CSS):
<table style="width:100%"> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr> <td>一月</td> <td style="text-align:right">¥3400</td> </tr> <tr> <td>二月</td> <td style="text-align:right">¥4500</td> </tr> </table>
مثال 3
كيفية إضافة لون الخلفية إلى خلية جدول (استخدام CSS):
<table> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr> <td style="background-color:#FF0000">一月</td> <td style="background-color:#00FF00">¥3400</td> </tr> </table>
例子 4
如何设置表格单元格的高度(使用 CSS):
<table> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr> <td style="height:100px">一月</td> <td style="height:100px">¥3400</td> </tr> </table>
例子 5
如何在表格单元格中规定不换行(使用 CSS):
<table> <tr> <th>诗</th> </tr> <tr> <td style="white-space:nowrap">朝辞白帝彩云间,千里江陵一日还。两岸猿声啼不住,轻舟已过万重山。</td> </tr> </table>
例子 6
如何垂直对齐 <td>
中的内容(使用 CSS):
<table style="width:50%;"> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr style="height:100px"> <td style="vertical-align:bottom">一月</td> <td style="vertical-align:bottom">¥3400</td> </tr> </table>
例子 7
如何设置表格单元格的宽度(使用 CSS):
<table style="width:100%"> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr> <td style="width:70%">一月</td> <td style="width:30%">¥3400</td> </tr> </table>
例子 8
如何创建表格标题:
<table> <tr> <th>姓名</th> <th>电邮</th> <th>电话</th> </tr> <tr> <td>Bill Gates</td> <td>bill.gates@example.com</td> <td>138-1234-5678</td> </tr> </table>
例子 9
如何创建带标题的表格:
<table> <caption>月份ly savings</caption> <tr> <th>月份</th> <th>储蓄</th> </tr> <tr> <td>一月</td> <td>¥3400</td> </tr> <tr> <td>二月</td> <td>¥4500</td> </tr> </table>
例子 10
如何定义跨越多行或多列的表格单元格:
<table> <tr> <th>姓名</th> <th>电邮</th> <th colspan="2">电话</th> </tr> <tr> <td>Bill Gates</td> <td>bill.gates@example.com</td> <td>138-1234-5678</td> <td>186-2345-6789</td> </tr> </table>
Attribute
Attribute | Value | Description |
---|---|---|
colspan | Number | Specify the number of columns the cell should span. |
headers | header_id | Specify one or more header cells related to the cell. |
rowspan | Number | Set the number of rows the cell should span. |
Global attributes
<td>
The tag also supports Global attributes in HTML.
event attributes
<td>
The tag also supports Event attributes in HTML.
Default CSS settings
Most browsers will use the following default values to display <td>
Element:
td { display: table-cell; vertical-align: inherit;
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous page <tbody>
- Next page <template>