[html] Make a td fixed size (width,height) while rest of td's can expand

Do you know, how to fix the size of a td Width and Height in a table allowing the rest of td on table to expand as needed?

The problem is that when there is data inside of td's it will not shrink more than the data, but if is empty it will shrink all the way, if you expand the window the td will expand.

I would like to keep the size of the td whether you expand or shrink the window and whether the td has data inside or not.

Also I need to keep the rest of td's able to expand as you expand window.

Class tableContainerRow2 is the one I need it to be a fixed size. e.g.

<style>
    .divContainer {
        margin:10px;
        background-color:#C7D8EE;
        border:2px solid #0076BF;
        text-align:left;    
    }

    .tableContainer {
        color:#0076BF;
        margin: -10px 0px -10px 0px;
        border-spacing: 10px;
        empty-cells:show;
        width:90%;
    }

    .tableContainerRow2 {
        background-color:white;
        border:2px solid #0076BF;
    }
</style>

<div class="divContainer">
    <table class="tableContainer" cellspacing="10px">
        <tr>
            <td width="18%" style="white-space:nowrap;" >NHS Number</td>
            <td width="17%">&#160;</td>
            <td width="10%"  style="white-space:nowrap;">Date of Visit</td>
            <td width="10%">&#160;</td>
            <td colspan="3" style="white-space:nowrap;">Care Time Started</td>
            <td width="4%">&#160;</td>
            <td width="5%">&#160;</td>
            <td width="25%" rowspan="2" style="font-weight:bold;vertical-align:middle;white-space:nowrap;">Tick when<br/> care starts</td>
        </tr>
        <tr >
            <td width="18%" class="tableContainerRow2">&#160;0123456789</td>
            <td width="17%">&#160;</td>
            <td width="10%" class="tableContainerRow2">&#160;12/12/09</td>
            <td width="10%">&#160;</td>
            <td width="5%" class="tableContainerRow2">&#160;12</td>
            <td width="1%" >&#160;:</td>
            <td width="5%" class="tableContainerRow2">&#160;10</td>                       
            <td width="4%">&#160;</td>
            <td width="5%">&#160;&#9745;</td>
            <td width="10%" >&#160;</td>
        </tr>
    </table>
</div>

This question is related to html html-table alignment

The answer is


just set the width of the td/column you want to be fixed and the rest will expand.

<td width="200"></td>

This will take care of the empty td:

<td style="min-width: 20px;"></td>

Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to html-table

Table column sizing DataTables: Cannot read property 'length' of undefined TypeError: a bytes-like object is required, not 'str' in python and CSV How to get the <td> in HTML tables to fit content, and let a specific <td> fill in the rest How to stick table header(thead) on top while scrolling down the table rows with fixed header(navbar) in bootstrap 3? Sorting table rows according to table header column using javascript or jquery How to make background of table cell transparent How to auto adjust table td width from the content bootstrap responsive table content wrapping How to print table using Javascript?

Examples related to alignment

How do I center text vertically and horizontally in Flutter? CSS align one item right with flexbox What's the difference between align-content and align-items? align images side by side in html How to align iframe always in the center How to make popup look at the centre of the screen? Responsive image align center bootstrap 3 How to align title at center of ActionBar in default theme(Theme.Holo.Light) Center align a column in twitter bootstrap How do I position an image at the bottom of div?