Question

I want to create a table should which contain two column with one header and one textbox each.

Here is the link of my needed table image..

Sample table Image

I the above table ..Name is header and My First and Last Name is text box. Like this next are their, one header and one textbox.

Here is my html table:

<body>
<table>
<thead>
    <tr>
        <th> <font color="#008eff" size="4px"> 1. Location of your  Hotel/Resort/Property </font> </th>
        <th></th>
        <th></th>
        <th></th>

    </tr>
</thead>
<tbody>
    <tr><th>Name <td> <input type="text"></td><td>Designation</td><td><input type="text"></td></tr>
    <tr><th>Organization</th><td><input type="text"></td><td>  </td><td>  </td></tr>
    <tr><th>Email</th><td><input type="text"></td><td>  </td><td>  </td></tr>
    <tr><th>Hotel/Resort/Property Name</th><td><input type="text"></td><td>Website address</td><td><input type="text"></td></tr>
</tbody>
</table>

</body>

But I am not able to create the exact table as in picture. Please help me ..

Was it helpful?

Solution 2

You could use this: Demo

CSS

.header {
    color: #008eff;
    font-size: 13pt;
    font-weight: bold;
}

.bold {
    font-weight: bold;
}

input {
    border: 0px;
    background-color: #eee;
}

td {
    border: 1px solid #ddd;
    background-color: #eee;
    height: 20px;
}

HTML

<table>
    <thead>
        <tr>
            <td colspan="4" class="header">1. Location of your Hotel/Resort/Property</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="bold">Name</td>
            <td><input type="text" /></td>
            <td class="bold">Designation</td>
            <td><input type="text" /></td>
        </tr>
        <tr>
            <td class="bold">Organization</td>
            <td><input type="text" /></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td class="bold">Email</td>
            <td><input type="text" /></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td class="bold">Hotel/Resort/Property Name</td>
            <td><input type="text" /></td>
            <td class="bold">Website address</td>
            <td><input type="text" /></td>
        </tr>
    </tbody>
</table>

OTHER TIPS

although slightly different than the attached image i think spanning over 4 columns is more right visually,

like this

<thead>
<tr>
    <th colspan=4 align="left"> <font color="#008eff" size="4px" > 1. Location of your  Hotel/Resort/Property </font> </th>


</tr>

Use colspan="2" in your first th tag.

<tr>
    <th colspan="2"> <font color="#008eff" size="4px"> 1. Location of your  Hotel/Resort/Property </font> </th>
    <th></th>
    <th></th>
    <th></th>  
</tr>

Check this demo jsFiddle

Use colspan when you want to merge columns. and Use rowspan for merge rows. read HTML table tag.

This will do the trick. Use Colspan to merge the columns and don't use tag again in second

<body>
<table>
<thead>
    <tr>
        <th colspan="2"> <font color="#008eff" size="4px"> 1. Location of your  Hotel/Resort/Property </font> </th>

        <th  colspan="2"></th>


    </tr>
</thead>
<tbody>
    <tr><td> <b>Name</b><td> <input type="text"></td><td>Designation</td><td><input type="text"></td></tr>
    <tr><td><b>Organization</b></td><td><input type="text"></td><td>  </td><td>  </td></tr>
    <tr><td>Email</td><td><input type="text"></td><td>  </td><td>  </td></tr>
    <tr><td>Hotel/Resort/Property Name</td><td><input type="text"></td><td>Website address</td><td><input type="text"></td></tr>
</tbody>
</table>

</body>

HTML

<table>
<thead>
    <tr>
        <th> <font color="#008eff" size="4px"> 1. Location of your  Hotel/Resort/Property </font> </th>
        <th></th>
    </tr>
</thead>
<tbody>
    <tr><td>Name <input type="text"></td><td>Designation<input type="text"></td></tr>
        <tr><td>Organization <input type="text"></td><td></td></tr>
            <tr><td>Email <input type="text"></td><td></td></tr>
    <tr><td>Hotel/Resort/Property Name <input type="text"></td><td>Website address <input type="text"></td></tr>
</tbody>
</table>

CSS

table
{
border-collapse:collapse;
width:700px;
}
table, th, td
{
border: 3px solid white;
background-color: #F2F2F2;
color:black;
}
th{
text-align:left;
}
input{
    float:right;
}

DEMO

Demo:

Live Demo

HTML:

    <table>
    <thead>
        <tr>
            <th colspan="2" class="heading">  1. Location of your  Hotel/Resort/Property 
            </th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th>Name </th>
                <td>
                    <input type="text" placeholder="Myfirstname and lastname"/>
                </td>
                <th>Designation</th>
                <td>
                    <input type="text" placeholder="My Designation name"/>
                </td>
        </tr>
        <tr>
            <th>Organization</th>
            <td>
                <input type="text" placeholder="My Organization"/>
            </td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <th>Email</th>
            <td>
                <input type="text" placeholder="My Email ID"/>
            </td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <th>Hotel/Resort/Property Name</th>
            <td>
                <input type="text" placeholder="My Organization"/>
            </td>
            <th>Website address</th>
            <td>
                <input type="text" placeholder="My Website address"/>
            </td>
        </tr>
    </tbody>
</table>

CSS

.heading
{
    color:#0083ff;
    font-size:12pt;
     background-color: #eee;
}
td,th
{

    text-align:left;
     background-color: #eee;
}

Output:

enter image description here

P.S :

The Mistakes in your code

To use Stylesheet you should know about two things they are ID and Class

ID is used to give style to a particular element,

whereas Class is used wherever you want the same style in different elements.

To know about Class & ID Click here..!!

Advantages of Using CSS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top