Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To create a table with a fixed element and two headers, you can use HTML code with the following steps:

  1. Open a new HTML file and add the following code to start the table:
<table>
  1. Add the first header row using the tag and the tag to define the header cells:
<tr>
  <th colspan="2">Header 1</th>
</tr>

The colspan attribute tells the browser that the header cell should span across two columns.

  1. Add the second header row with another tag and two tags:
<tr>
  <th>Fixed Element</th>
  <th>Header 2</th>
</tr>
  1. Add the table rows with the tag and tags to define the cells:
<tr>
  <td>Row 1 Cell 1</td>
  <td>Row 1 Cell 2</td>
</tr>
<tr>
  <td>Row 2 Cell 1</td>
  <td>Row 2 Cell 2</td>
</tr>
  1. Close the table using the tag:
</table>

Here is the complete HTML code for a table with a fixed element and two headers:

<table>
  <tr>
    <th colspan="2">Header 1</th>
  </tr>
  <tr>
    <th>Fixed Element</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Row 1 Cell 1</td>
    <td>Row 1 Cell 2</td>
  </tr>
  <tr>
    <td>Row 2 Cell 1</td>
    <td>Row 2 Cell 2</td>
  </tr>
</table>