1

Semantically I have a table so I would use the HTML <table> element. For grouping rows I can use <tbody>:

<table>
    <tbody>
        <tr><td>A</td><td>1</td></tr>
        <tr><td>B</td><td>1</td></tr>
        ...
    </tbody>
    <tbody>
        <tr><td>a</td><td>1</td></tr>
        <tr><td>b</td><td>2</td></tr>
        ...
    </tbody>
</tbody>

At each <tbody> I want to (outside of the table on the left) have a link/heading/anchor identifying that subsection. If I make the <table> display:grid and have each <tbody> generate a row I would have the grid lines necessary to place the link/heading/anchor to the left.

However, these grid lines would be contained by the table and not extend beyond, so I couldn't "lay" anything on them. I guess I'm looking for an inverse of subgrid which lets you have a bigger grid and nest a subgrid into it. But I want to have a grid and extend from the smaller grid:

subgrid with overhangs--potentially a larger parent grid

9
  • 2
    Do NOT make an actual table into display:grid. Use divs in proper containers. Commented Oct 8 at 19:06
  • I'm on the same page along @Paulie_D. Use div's instead table. With some div tags and proper css styling by using Grid layout. Commented Oct 8 at 19:13
  • 2
    I have no problem with using display: grid on an HTML table. but it's not at all clear how the link/heading/anchor fits into that semantic table structure, as it surely should. Can you clarify that? Commented Oct 8 at 21:16
  • 2
    I understand your requirement to keep it as a table for the semantics, but I'm not clear why you are not wanting that left hand side info to be part of the table - could you explain why it cannot be? Commented Oct 9 at 9:17
  • 3
    You can use th, td + rowspan and remove borders ..... Commented Oct 9 at 18:30

1 Answer 1

0

As you want to keep an HTML table for semantic reasons, incorporate the first column with the DATA (links) into it.

This snippet put them into the first cell of the first row of each group. They are then set to span their rowset.

There are various ways of drawing the 'extended' line. This snippet puts a border round each cell then removes the ones that aren't needed.

<style>
  table {
    border-collapse: collapse;
  }

  td {
    border: solid 1px black;
  }

  tr:first-child td {
    border-top: solid 1px transparent;
    border-left: solid 1px transparent;
    vertical-align: bottom;
  }
</style>
<table>
  <tbody>
    <tr>
      <td rowspan="4">DATA</div>
      </td>
      <td>A</td>
      <td>1</td>
    </tr>
    <tr>
      <td>B</td>
      <td>1</td>
    </tr>
    <tr>
      <td>C</td>
      <td>1</td>
    </tr>
    <tr>
      <td>D</td>
      <td>1</td>
    </tr>
  </tbody>
  <tbody>
    <tr>
      <td rowspan="2">DATA</div>
      </td>
      <td>a</td>
      <td>1</td>
    </tr>
    <tr>
      <td>b</td>
      <td>2</td>
    </tr>
  </tbody>
  </tbody>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.