65

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
esqew
  • 42,425
  • 27
  • 92
  • 132

3 Answers3

120

Set the colspan attribute to 2.

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

icktoofay
  • 126,289
  • 21
  • 250
  • 231
107

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

Mudassir
  • 13,031
  • 8
  • 59
  • 87
3

Use colspan for do this:

 <td colspan="3">PUR mix up column</td>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Smoke
  • 89
  • 1
  • 8
  • 15