Make input box just fill a table cell

I can put an HTML input box inside a table cell like this

<TD COLWIDTH='50' ><INPUT type='text' size='**some number**' value='123456'></TD>

BUT
if ‘some number’ is such that the input box is too large, it pushes the cell wider than the value specified in the COLWIDTH

Is there a way to specify that the input box should just fill the cell?

What I mean is that If the input box wants to be smaller than COLWIDTH then it should expand to fill the cell width and if the input box wants to be bigger than the cell then it would just shrink the size of the cell.

PS: NOBODY uses width’s in HTML anymore! No colwidth’s are ever used. They are done in CSS !!!

Good o. And so can you send the style sheet code to show how to make the input box just fill the cell and not push it wider.

Not sure if that is what you wanted. But, you just put in the values you want to use.
Sometimes it is handy or perhaps more useful to use max-width: 50px; instead of just width.

You can use styles as well using the following codes in your HTML
Add the following to your HTML after the title

<link rel="stylesheet" type="text/css" href="styles.css">

add this to the body

<td class='width1' ><input type='text' value='123456' class='width2'></TD>        

styles.css

.width1{
width: 50px;
}

.width2{
background-color: #dadada;
width: 45px;
}

Hope this helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service