Splitting a table cell into two columns in HTML

前端 未结 8 932
感动是毒
感动是毒 2020-12-05 22:43

I have the following table:

Header Header
相关标签:
8条回答
  • 2020-12-05 23:21

    I came here for a similar problem I was facing with my table headers.

    @MrMisterMan's answer, as well as others, were really helpful, but the borders were beating my game. So, I did some research to find the use rowspan.

    Here's what I did and I guess it might help others facing something similar.

    <table style="width: 100%; margin-top: 10px; font-size: 0.8em;" border="1px">
        <tr align="center" >
            <th style="padding:2.5px; width: 10%;" rowspan="2">Item No</th>
            <th style="padding:2.5px; width: 55%;" rowspan="2">DESCRIPTION</th>
            <th style="padding:2.5px;" rowspan="2">Quantity</th>
            <th style="padding:2.5px;" colspan="2">Rate per Item</th>
            <th style="padding:2.5px;" colspan="2">AMOUNT</th>
        </tr>
        <tr>
            <th>Rs.</th>
            <th>P.</th>
            <th>Rs.</th>
            <th>P.</th>
        </tr>
    </table>

    0 讨论(0)
  • 2020-12-05 23:29

    Please try this way.

    <table border="1">
        <tr>
            <th scope="col">Header</th>
            <th scope="col">Header</th>
            <th colspan="2">Header</th>
        </tr> 
        <tr>
            <td scope="row">&nbsp;</td>
            <td scope="row">&nbsp;</td>
            <td scope="col">Split this one</td>
            <td scope="col">into two columns</td>
        </tr>
    </table>
    
    0 讨论(0)
提交回复
热议问题