1

My goal is to make each TD have a width of 100px which should also make the input fields be 100px. However, when I added width="100" to a TD, nothing happens. Here's the HTML code:

<table>
    <tr>
        <td>2.</td>
        <td width="100">
            <input type="text" name="year2" id="year2" value="" />
        </td>
        <td width="100">
            <input type="text" name="make2" id="make2" value="" />
        </td>
        <td width="100">
            <input type="text" name="vin2" id="vin2" value="" />
        </td>
        <td width="100">
            <input type="text" name="radius2" id="radius2" value="" />
        </td>
        <td width="100">
            <input type="text" name="gvm2" id="gvm2" value="" />
        </td>
        <td width="100">
            <input type="text" name="comp2" id="comp2" value="" />
        </td>
        <td width="100">
            <input type="text" name="coll2" id="coll21" value="" />
        </td>
        <td width="100">
            <input type="text" name="amt2" id="amt2" value="" />
        </td>
    </tr>
</table>

Here's a link to the JSFiddle

I would appreciate any help.

2 Answers 2

1

The style should be added on your <input> not on your <td>. Also you should manage this via CSS instead of using inline styles.

In your CSS add

.my-width {
    width: 100px;
}

Then add that class to each of your inputs:

<input class="my-width" type="text" name="year2" id="year2" value="" />

JS Fiddle Demo

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

Comments

1

Add style="width: 100px" to each input or add to your css file

input[type="text"]{
    width: 100px;
}

Here is fiddle for the second option

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.