Search code examples
htmlmarkdown

Ordered list spanning table rows


I want to create a question form in a Markdown/HTML page, with each question having a number.

 QUESTIONS         |  ANSWERS          |
-------------------|-------------------|
1. First Question  |                   |
-------------------|-------------------|
2. Second Question |                   | 
-------------------|-------------------|
3. Third Question  |                   |
-------------------|-------------------|

It seems the best way to do this is as a table. But code like this:

        <td>
            <ol>
                <li>First Question</li>
            </ol>
        </td>
        <td>
            <br>
        </td>
    </tr>
        <td>
            <ol>
                <li>Second Question</li>
            </ol>
        </td>
        <td>
            <br>
        </td>
    </tr>
        <td>
            <ol>
                <li>Third Question</li>
            </ol>
        </td>
        <td>
            <br>
        </td>
    </tr>

Gives me a table like this:

 QUESTIONS         |  ANSWERS          |
-------------------|-------------------|
1. First Question  |                   |
-------------------|-------------------|
1. Second Question |                   | 
-------------------|-------------------|
1. Third Question  |                   |
-------------------|-------------------|

When I try googling this, I see instructions on how to have an ordered list within a table cell.

Is it possible to do what I want?


Solution

  • You can put the "ol" element outside your table definition, and then just the "li" elements within the table cells.

    <ol>
    <table>
    <tr><td>QUESTIONS</td><td>ANSWERS</td></tr>
    <tr><td><li>First Question</li></td><td></td></tr>
    <tr><td><li>Second Question</li></td><td></td></tr>
    <tr><td><li>Third Question</li></td><td></td></tr>
    </table>
    </ol>