合并两个 HTML 表格单元格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4342336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:33:53  来源:igfitidea点击:

Merge two HTML table cells

htmlhtml-table

提问by esqew

I'm creating a table in HTML and I'd like to have my top cell be the width of two. Here's a rough drawing:

我正在用 HTML 创建一个表格,我希望顶部单元格的宽度为 2。这是一张粗略的图:

__________________________________________
|                HEADER                  |
|                                        |
==========================================
|                  ||                    |
|     CONTENT      ||       CONTENT      |
|                  ||                    |
------------------------------------------

Is there any way to accomplish this in HTML?

有什么方法可以在 HTML 中完成此操作吗?

回答by icktoofay

Set the colspanattribute to 2.

colspan属性设置为 2。

...but please don't use tables for layout.

...但请不要使用表格进行布局

回答by Mudassir

Add an attribute colspan(abbriviation for 'column span') in your top cell (<td>) and set its value to 2. Your table should resembles the following;

colspan在顶部单元格 ( <td>) 中添加一个属性(“列跨度”的缩写)并将其值设置为 2。您的表格应类似于以下内容;

<table>
    <tr>
        <td colspan = "2">
            <!-- Merged Columns -->
        </td>
    </tr>

    <tr>
        <td>
            <!-- Column 1 -->
        </td>

        <td>
            <!-- Column 2 -->
        </td>
    </tr>
</table>

See also
     W3 official docs on HTML Tables

另请参阅
     有关 HTML 表格的 W3 官方文档

回答by Smoke

use colspan for do this

使用 colspan 来做到这一点

 <td colspan="3">PUR mix up column</td>