开发者

Merge two HTML table cells

开发者 https://www.devze.com 2023-01-28 11:05 出处:网络
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:

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:

__________________________________________
|                开发者_运维技巧HEADER                  |
|                                        |
==========================================
|                  ||                    |
|     CONTENT      ||       CONTENT      |
|                  ||                    |
------------------------------------------

Is there a way to accomplish this in HTML?


Set the colspan attribute to 2.

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


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;

<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


Use colspan for do this:

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

精彩评论

暂无评论...
验证码 换一张
取 消