1

I'm using JotForm and I have to style some table with only CSS. My problem is how can i integrate two rows, first row is header and second row is input section. But I can't explain what my problem is. Just see the code and try to solve my problem please.

HTML:

<table>
    <tr>
        <th>Company Name</th>
        <th>Company Name</th>
        <th>Company Name</th>
        <th>Company Name</th>
        <th>Company Name</th>
    </tr>
    <tr>
        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
    </tr>
</table>

CSS:

tr {
    display: table;
    width: 800px;
}

td {
    display: inline-table; 
    width: 25%;
}

th {
    display: inline-table; 
    width: 25%;
    background-color: red;
    color: #fff;
    font-weight: 500;
}

Result of code

result

I want it to be like

Picture2

Is there way to solve this with only css?

Prajwal
  • 3,930
  • 5
  • 24
  • 50

3 Answers3

0

try this on you need to change html format why you want use table for this.that`s not good way

<table>
<tr>
    <th>Company Name</th>
    <th>Company Name</th>
    <th>Company Name</th>
</tr>
<tr>
    <td><input type="text" name="" placeholder="Write here"></td>
    <td><input type="text" name="" placeholder="Write here"></td>
    <td><input type="text" name="" placeholder="Write here"></td>
 </tr>
  <tr>
        <th>Company Name</th>
         <th>Company Name</th>
 </tr>
 <tr>
    <td><input type="text" name="" placeholder="Write here"></td>
    <td><input type="text" name="" placeholder="Write here"></td>
</tr>

Reena Mori
  • 647
  • 6
  • 15
0

you can like this.I hope it will help you:

<table>
    <tr>
        <th>Company Name</th>
        <th>Company Name</th>
        <th>Company Name</th>
        </tr>
        <tr>
         <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
        </tr>

        <th>Company Name</th>
        <th>Company Name</th>
    </tr>
    <tr>

        <td><input type="text" name="" placeholder="Write here"></td>
        <td><input type="text" name="" placeholder="Write here"></td>
    </tr>
</table>
<style>
tr th{
background-color: red;
color:white;
}
</style>
PHP Geek
  • 3,949
  • 1
  • 16
  • 32
0

Just use inline-block.

td {
    display: inline-table; 
    width: 25%;
}

th {
    display: inline-table; 
    width: 25%;
    background-color: red;
    color: #fff;
    font-weight: 500;
}
You Kpop
  • 1
  • 1