HTML table with variable, fixed, and remaining width












3















I need to create an HTML table with the following layout:



[Name] [Message] Date]



Where the width of [Name] should be the width of the longest name (Up to a max), [Date]should be a fixed width of 95px (And floating to the right), while [Message] should take the remaining width.



I've tried using multiple div's, but I can't get the result I need, and a table seems much simpler.



So far, the following isn't working:



<table style="width: 100%">
<tr>
<td style="width: 100%; max-width: 100px">NAME</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
<tr>
<td style="width: 100%; max-width: 100px">NAME OTHER</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
</table>



Edit 1 Seems as though this example has exactly what I need. Although I still think a table would be neater.
Edit 2 The [Message] needs to allow for multiline...
Edit 3 Here is a working sample of what I need (Exactly) based on the link in Edit 1











share|improve this question

























  • i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

    – Fabian Harmsen
    Jan 17 '14 at 7:01






  • 2





    @FabianHarmsen : styling in PHP....enlighten me please!!! :

    – NoobEditor
    Jan 17 '14 at 7:01











  • you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

    – Fabian Harmsen
    Jan 17 '14 at 7:06






  • 1





    @DamienJoe : OP quoted that thread in his question.... :)

    – NoobEditor
    Jan 17 '14 at 7:10











  • @NoobEditor okay

    – Zo Has
    Jan 17 '14 at 7:10
















3















I need to create an HTML table with the following layout:



[Name] [Message] Date]



Where the width of [Name] should be the width of the longest name (Up to a max), [Date]should be a fixed width of 95px (And floating to the right), while [Message] should take the remaining width.



I've tried using multiple div's, but I can't get the result I need, and a table seems much simpler.



So far, the following isn't working:



<table style="width: 100%">
<tr>
<td style="width: 100%; max-width: 100px">NAME</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
<tr>
<td style="width: 100%; max-width: 100px">NAME OTHER</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
</table>



Edit 1 Seems as though this example has exactly what I need. Although I still think a table would be neater.
Edit 2 The [Message] needs to allow for multiline...
Edit 3 Here is a working sample of what I need (Exactly) based on the link in Edit 1











share|improve this question

























  • i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

    – Fabian Harmsen
    Jan 17 '14 at 7:01






  • 2





    @FabianHarmsen : styling in PHP....enlighten me please!!! :

    – NoobEditor
    Jan 17 '14 at 7:01











  • you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

    – Fabian Harmsen
    Jan 17 '14 at 7:06






  • 1





    @DamienJoe : OP quoted that thread in his question.... :)

    – NoobEditor
    Jan 17 '14 at 7:10











  • @NoobEditor okay

    – Zo Has
    Jan 17 '14 at 7:10














3












3








3








I need to create an HTML table with the following layout:



[Name] [Message] Date]



Where the width of [Name] should be the width of the longest name (Up to a max), [Date]should be a fixed width of 95px (And floating to the right), while [Message] should take the remaining width.



I've tried using multiple div's, but I can't get the result I need, and a table seems much simpler.



So far, the following isn't working:



<table style="width: 100%">
<tr>
<td style="width: 100%; max-width: 100px">NAME</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
<tr>
<td style="width: 100%; max-width: 100px">NAME OTHER</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
</table>



Edit 1 Seems as though this example has exactly what I need. Although I still think a table would be neater.
Edit 2 The [Message] needs to allow for multiline...
Edit 3 Here is a working sample of what I need (Exactly) based on the link in Edit 1











share|improve this question
















I need to create an HTML table with the following layout:



[Name] [Message] Date]



Where the width of [Name] should be the width of the longest name (Up to a max), [Date]should be a fixed width of 95px (And floating to the right), while [Message] should take the remaining width.



I've tried using multiple div's, but I can't get the result I need, and a table seems much simpler.



So far, the following isn't working:



<table style="width: 100%">
<tr>
<td style="width: 100%; max-width: 100px">NAME</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
<tr>
<td style="width: 100%; max-width: 100px">NAME OTHER</td>
<td style="width: 100%">message</td>
<td style="width: 95px">TIME</td>
</tr>
</table>



Edit 1 Seems as though this example has exactly what I need. Although I still think a table would be neater.
Edit 2 The [Message] needs to allow for multiline...
Edit 3 Here is a working sample of what I need (Exactly) based on the link in Edit 1








html css html-table






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 23:11









Brian Tompsett - 汤莱恩

4,1831337101




4,1831337101










asked Jan 17 '14 at 6:58









TheGeekZnTheGeekZn

1,68763368




1,68763368













  • i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

    – Fabian Harmsen
    Jan 17 '14 at 7:01






  • 2





    @FabianHarmsen : styling in PHP....enlighten me please!!! :

    – NoobEditor
    Jan 17 '14 at 7:01











  • you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

    – Fabian Harmsen
    Jan 17 '14 at 7:06






  • 1





    @DamienJoe : OP quoted that thread in his question.... :)

    – NoobEditor
    Jan 17 '14 at 7:10











  • @NoobEditor okay

    – Zo Has
    Jan 17 '14 at 7:10



















  • i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

    – Fabian Harmsen
    Jan 17 '14 at 7:01






  • 2





    @FabianHarmsen : styling in PHP....enlighten me please!!! :

    – NoobEditor
    Jan 17 '14 at 7:01











  • you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

    – Fabian Harmsen
    Jan 17 '14 at 7:06






  • 1





    @DamienJoe : OP quoted that thread in his question.... :)

    – NoobEditor
    Jan 17 '14 at 7:10











  • @NoobEditor okay

    – Zo Has
    Jan 17 '14 at 7:10

















i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

– Fabian Harmsen
Jan 17 '14 at 7:01





i think in HTML is this difficult, use javascript or PHP. for PHP i kann give you an example

– Fabian Harmsen
Jan 17 '14 at 7:01




2




2





@FabianHarmsen : styling in PHP....enlighten me please!!! :

– NoobEditor
Jan 17 '14 at 7:01





@FabianHarmsen : styling in PHP....enlighten me please!!! :

– NoobEditor
Jan 17 '14 at 7:01













you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

– Fabian Harmsen
Jan 17 '14 at 7:06





you can use HTML code and css in PHP too under stand ist so that he want to read something and make a table out of that. It shoud not be a Problem

– Fabian Harmsen
Jan 17 '14 at 7:06




1




1





@DamienJoe : OP quoted that thread in his question.... :)

– NoobEditor
Jan 17 '14 at 7:10





@DamienJoe : OP quoted that thread in his question.... :)

– NoobEditor
Jan 17 '14 at 7:10













@NoobEditor okay

– Zo Has
Jan 17 '14 at 7:10





@NoobEditor okay

– Zo Has
Jan 17 '14 at 7:10












3 Answers
3






active

oldest

votes


















1














This cannot be done in CSS alone, due to the requirements. The first column should be flexible, which is easy (just prevent line breaks and let the column take its natural width), and setting the last column width is trivial, but telling the browser to use all the rest in the mid column (instead of expanding the first column too) cannot be done in CSS. If you set its width to 100%, things work the desired way in some browsers, but other browsers (like IE) treat it differently. You would require a width of something plus 100% plus 95px to equal 100%, which is of course impossible, and browsers handle this in different ways.



However, with a little bit of JavaScript the medicine goes down: do as outlined above, with 100%, then postprocess the table by setting the first column to a specific width in pixels (using the value allocated by the browser), remove the width: 100% setting, and set table layout to fixed—which means that the browser now has two columns width fixed width, total width set to 100%, and one column with no width set, so it is easy to it to allocate the remaining width to the mid column.



<style>
td:first-child { white-space: nowrap }
td:nth-child(2) { width: 100% }
td:nth-child(3) { width: 95px }
</style>
<table border cellspacing=0 style="width: 100%">
<tr>
<td style="">NAME</td>
<td style="">message</td>
<td style="width:95px">TIME</td>
</tr>
<tr>
<td>NAME OTHER</td>
<td>message</td>
<td>TIME</td>
</tr>
</table>
<script>
(function () {
var row = document.getElementsByTagName('tr')[0];
var cell1 = row.children[0];
cell1.style.width = cell1.clientWidth + 'px';
row.children[1].style.width = 'auto';
document.getElementsByTagName('table')[0].style.tableLayout = 'fixed';
})();
</script>


For simplicity, this code is based on the assumption that there are no other tables on the page. Modify as needed. The attributes border cellspacing=0 are there just make the cell widths more visible.



Update: This does not address the issue of setting a maximum width on the first column. That requirement is underdefined unless you specify what should happen if the width is exceeded (truncation, word wrap, wrap anywhere, wrap with hyphenation?).






share|improve this answer


























  • I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

    – TheGeekZn
    Jan 17 '14 at 11:16



















0














try this code .



.test
{
max-width:100px;
}


<table style="text-align: center;">
<tr>
<th>NAME</th>
<th>message</th>
<th style="width: 95px">TIME</th>
</tr>
<tr>
<td class="test">NAME OTHER</td>
<td>message</td>
<td style="width: 95px">TIME</td>
</tr>
</table>





share|improve this answer































    0














    The following .css code provides the template for the attached picture:



        table {
    display: table;
    width: 100%;
    table-layout: fixed;
    position: absolute;
    top: 10px;
    empty-cells: hide;
    }

    td.small:first-Child {
    vertical-align: top;
    width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    }

    td.small:last-Child {
    vertical-align: top;
    width: 95px;
    }

    td.extend {
    vertical-align: top;
    word-wrap: break-word;
    }

    .userName a {
    color: #9DC8FC;
    }




    <tr>
    <td class="small userName">
    <a title="Administrator" href="#">Administrator</a>
    </td>
    <td class="extend">
    is it me you're looking for?
    </td>
    <td class="small">
    10:14:01 AM
    </td>
    </tr>


    Chatbox






    share|improve this answer
























    • so this is the answer??? :)

      – NoobEditor
      Jan 17 '14 at 8:35











    • For me it is... If you want your table looking like that, then yes :)

      – TheGeekZn
      Jan 17 '14 at 9:12






    • 1





      given +1...mark it as accepted too!! :)

      – NoobEditor
      Jan 17 '14 at 9:14











    • This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

      – Jukka K. Korpela
      Jan 17 '14 at 10:58











    • @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

      – TheGeekZn
      Jan 17 '14 at 11:14













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21179718%2fhtml-table-with-variable-fixed-and-remaining-width%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    This cannot be done in CSS alone, due to the requirements. The first column should be flexible, which is easy (just prevent line breaks and let the column take its natural width), and setting the last column width is trivial, but telling the browser to use all the rest in the mid column (instead of expanding the first column too) cannot be done in CSS. If you set its width to 100%, things work the desired way in some browsers, but other browsers (like IE) treat it differently. You would require a width of something plus 100% plus 95px to equal 100%, which is of course impossible, and browsers handle this in different ways.



    However, with a little bit of JavaScript the medicine goes down: do as outlined above, with 100%, then postprocess the table by setting the first column to a specific width in pixels (using the value allocated by the browser), remove the width: 100% setting, and set table layout to fixed—which means that the browser now has two columns width fixed width, total width set to 100%, and one column with no width set, so it is easy to it to allocate the remaining width to the mid column.



    <style>
    td:first-child { white-space: nowrap }
    td:nth-child(2) { width: 100% }
    td:nth-child(3) { width: 95px }
    </style>
    <table border cellspacing=0 style="width: 100%">
    <tr>
    <td style="">NAME</td>
    <td style="">message</td>
    <td style="width:95px">TIME</td>
    </tr>
    <tr>
    <td>NAME OTHER</td>
    <td>message</td>
    <td>TIME</td>
    </tr>
    </table>
    <script>
    (function () {
    var row = document.getElementsByTagName('tr')[0];
    var cell1 = row.children[0];
    cell1.style.width = cell1.clientWidth + 'px';
    row.children[1].style.width = 'auto';
    document.getElementsByTagName('table')[0].style.tableLayout = 'fixed';
    })();
    </script>


    For simplicity, this code is based on the assumption that there are no other tables on the page. Modify as needed. The attributes border cellspacing=0 are there just make the cell widths more visible.



    Update: This does not address the issue of setting a maximum width on the first column. That requirement is underdefined unless you specify what should happen if the width is exceeded (truncation, word wrap, wrap anywhere, wrap with hyphenation?).






    share|improve this answer


























    • I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

      – TheGeekZn
      Jan 17 '14 at 11:16
















    1














    This cannot be done in CSS alone, due to the requirements. The first column should be flexible, which is easy (just prevent line breaks and let the column take its natural width), and setting the last column width is trivial, but telling the browser to use all the rest in the mid column (instead of expanding the first column too) cannot be done in CSS. If you set its width to 100%, things work the desired way in some browsers, but other browsers (like IE) treat it differently. You would require a width of something plus 100% plus 95px to equal 100%, which is of course impossible, and browsers handle this in different ways.



    However, with a little bit of JavaScript the medicine goes down: do as outlined above, with 100%, then postprocess the table by setting the first column to a specific width in pixels (using the value allocated by the browser), remove the width: 100% setting, and set table layout to fixed—which means that the browser now has two columns width fixed width, total width set to 100%, and one column with no width set, so it is easy to it to allocate the remaining width to the mid column.



    <style>
    td:first-child { white-space: nowrap }
    td:nth-child(2) { width: 100% }
    td:nth-child(3) { width: 95px }
    </style>
    <table border cellspacing=0 style="width: 100%">
    <tr>
    <td style="">NAME</td>
    <td style="">message</td>
    <td style="width:95px">TIME</td>
    </tr>
    <tr>
    <td>NAME OTHER</td>
    <td>message</td>
    <td>TIME</td>
    </tr>
    </table>
    <script>
    (function () {
    var row = document.getElementsByTagName('tr')[0];
    var cell1 = row.children[0];
    cell1.style.width = cell1.clientWidth + 'px';
    row.children[1].style.width = 'auto';
    document.getElementsByTagName('table')[0].style.tableLayout = 'fixed';
    })();
    </script>


    For simplicity, this code is based on the assumption that there are no other tables on the page. Modify as needed. The attributes border cellspacing=0 are there just make the cell widths more visible.



    Update: This does not address the issue of setting a maximum width on the first column. That requirement is underdefined unless you specify what should happen if the width is exceeded (truncation, word wrap, wrap anywhere, wrap with hyphenation?).






    share|improve this answer


























    • I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

      – TheGeekZn
      Jan 17 '14 at 11:16














    1












    1








    1







    This cannot be done in CSS alone, due to the requirements. The first column should be flexible, which is easy (just prevent line breaks and let the column take its natural width), and setting the last column width is trivial, but telling the browser to use all the rest in the mid column (instead of expanding the first column too) cannot be done in CSS. If you set its width to 100%, things work the desired way in some browsers, but other browsers (like IE) treat it differently. You would require a width of something plus 100% plus 95px to equal 100%, which is of course impossible, and browsers handle this in different ways.



    However, with a little bit of JavaScript the medicine goes down: do as outlined above, with 100%, then postprocess the table by setting the first column to a specific width in pixels (using the value allocated by the browser), remove the width: 100% setting, and set table layout to fixed—which means that the browser now has two columns width fixed width, total width set to 100%, and one column with no width set, so it is easy to it to allocate the remaining width to the mid column.



    <style>
    td:first-child { white-space: nowrap }
    td:nth-child(2) { width: 100% }
    td:nth-child(3) { width: 95px }
    </style>
    <table border cellspacing=0 style="width: 100%">
    <tr>
    <td style="">NAME</td>
    <td style="">message</td>
    <td style="width:95px">TIME</td>
    </tr>
    <tr>
    <td>NAME OTHER</td>
    <td>message</td>
    <td>TIME</td>
    </tr>
    </table>
    <script>
    (function () {
    var row = document.getElementsByTagName('tr')[0];
    var cell1 = row.children[0];
    cell1.style.width = cell1.clientWidth + 'px';
    row.children[1].style.width = 'auto';
    document.getElementsByTagName('table')[0].style.tableLayout = 'fixed';
    })();
    </script>


    For simplicity, this code is based on the assumption that there are no other tables on the page. Modify as needed. The attributes border cellspacing=0 are there just make the cell widths more visible.



    Update: This does not address the issue of setting a maximum width on the first column. That requirement is underdefined unless you specify what should happen if the width is exceeded (truncation, word wrap, wrap anywhere, wrap with hyphenation?).






    share|improve this answer















    This cannot be done in CSS alone, due to the requirements. The first column should be flexible, which is easy (just prevent line breaks and let the column take its natural width), and setting the last column width is trivial, but telling the browser to use all the rest in the mid column (instead of expanding the first column too) cannot be done in CSS. If you set its width to 100%, things work the desired way in some browsers, but other browsers (like IE) treat it differently. You would require a width of something plus 100% plus 95px to equal 100%, which is of course impossible, and browsers handle this in different ways.



    However, with a little bit of JavaScript the medicine goes down: do as outlined above, with 100%, then postprocess the table by setting the first column to a specific width in pixels (using the value allocated by the browser), remove the width: 100% setting, and set table layout to fixed—which means that the browser now has two columns width fixed width, total width set to 100%, and one column with no width set, so it is easy to it to allocate the remaining width to the mid column.



    <style>
    td:first-child { white-space: nowrap }
    td:nth-child(2) { width: 100% }
    td:nth-child(3) { width: 95px }
    </style>
    <table border cellspacing=0 style="width: 100%">
    <tr>
    <td style="">NAME</td>
    <td style="">message</td>
    <td style="width:95px">TIME</td>
    </tr>
    <tr>
    <td>NAME OTHER</td>
    <td>message</td>
    <td>TIME</td>
    </tr>
    </table>
    <script>
    (function () {
    var row = document.getElementsByTagName('tr')[0];
    var cell1 = row.children[0];
    cell1.style.width = cell1.clientWidth + 'px';
    row.children[1].style.width = 'auto';
    document.getElementsByTagName('table')[0].style.tableLayout = 'fixed';
    })();
    </script>


    For simplicity, this code is based on the assumption that there are no other tables on the page. Modify as needed. The attributes border cellspacing=0 are there just make the cell widths more visible.



    Update: This does not address the issue of setting a maximum width on the first column. That requirement is underdefined unless you specify what should happen if the width is exceeded (truncation, word wrap, wrap anywhere, wrap with hyphenation?).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 17 '14 at 11:29

























    answered Jan 17 '14 at 11:11









    Jukka K. KorpelaJukka K. Korpela

    150k24184292




    150k24184292













    • I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

      – TheGeekZn
      Jan 17 '14 at 11:16



















    • I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

      – TheGeekZn
      Jan 17 '14 at 11:16

















    I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

    – TheGeekZn
    Jan 17 '14 at 11:16





    I really like this answer. I was trying to prevent any JQuery though, just to make the solution lighter. If viewers vote this answer above mine, though, I will mark it as correct :)

    – TheGeekZn
    Jan 17 '14 at 11:16













    0














    try this code .



    .test
    {
    max-width:100px;
    }


    <table style="text-align: center;">
    <tr>
    <th>NAME</th>
    <th>message</th>
    <th style="width: 95px">TIME</th>
    </tr>
    <tr>
    <td class="test">NAME OTHER</td>
    <td>message</td>
    <td style="width: 95px">TIME</td>
    </tr>
    </table>





    share|improve this answer




























      0














      try this code .



      .test
      {
      max-width:100px;
      }


      <table style="text-align: center;">
      <tr>
      <th>NAME</th>
      <th>message</th>
      <th style="width: 95px">TIME</th>
      </tr>
      <tr>
      <td class="test">NAME OTHER</td>
      <td>message</td>
      <td style="width: 95px">TIME</td>
      </tr>
      </table>





      share|improve this answer


























        0












        0








        0







        try this code .



        .test
        {
        max-width:100px;
        }


        <table style="text-align: center;">
        <tr>
        <th>NAME</th>
        <th>message</th>
        <th style="width: 95px">TIME</th>
        </tr>
        <tr>
        <td class="test">NAME OTHER</td>
        <td>message</td>
        <td style="width: 95px">TIME</td>
        </tr>
        </table>





        share|improve this answer













        try this code .



        .test
        {
        max-width:100px;
        }


        <table style="text-align: center;">
        <tr>
        <th>NAME</th>
        <th>message</th>
        <th style="width: 95px">TIME</th>
        </tr>
        <tr>
        <td class="test">NAME OTHER</td>
        <td>message</td>
        <td style="width: 95px">TIME</td>
        </tr>
        </table>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 17 '14 at 7:39









        Puneet PurohitPuneet Purohit

        70541533




        70541533























            0














            The following .css code provides the template for the attached picture:



                table {
            display: table;
            width: 100%;
            table-layout: fixed;
            position: absolute;
            top: 10px;
            empty-cells: hide;
            }

            td.small:first-Child {
            vertical-align: top;
            width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            }

            td.small:last-Child {
            vertical-align: top;
            width: 95px;
            }

            td.extend {
            vertical-align: top;
            word-wrap: break-word;
            }

            .userName a {
            color: #9DC8FC;
            }




            <tr>
            <td class="small userName">
            <a title="Administrator" href="#">Administrator</a>
            </td>
            <td class="extend">
            is it me you're looking for?
            </td>
            <td class="small">
            10:14:01 AM
            </td>
            </tr>


            Chatbox






            share|improve this answer
























            • so this is the answer??? :)

              – NoobEditor
              Jan 17 '14 at 8:35











            • For me it is... If you want your table looking like that, then yes :)

              – TheGeekZn
              Jan 17 '14 at 9:12






            • 1





              given +1...mark it as accepted too!! :)

              – NoobEditor
              Jan 17 '14 at 9:14











            • This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

              – Jukka K. Korpela
              Jan 17 '14 at 10:58











            • @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

              – TheGeekZn
              Jan 17 '14 at 11:14


















            0














            The following .css code provides the template for the attached picture:



                table {
            display: table;
            width: 100%;
            table-layout: fixed;
            position: absolute;
            top: 10px;
            empty-cells: hide;
            }

            td.small:first-Child {
            vertical-align: top;
            width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            }

            td.small:last-Child {
            vertical-align: top;
            width: 95px;
            }

            td.extend {
            vertical-align: top;
            word-wrap: break-word;
            }

            .userName a {
            color: #9DC8FC;
            }




            <tr>
            <td class="small userName">
            <a title="Administrator" href="#">Administrator</a>
            </td>
            <td class="extend">
            is it me you're looking for?
            </td>
            <td class="small">
            10:14:01 AM
            </td>
            </tr>


            Chatbox






            share|improve this answer
























            • so this is the answer??? :)

              – NoobEditor
              Jan 17 '14 at 8:35











            • For me it is... If you want your table looking like that, then yes :)

              – TheGeekZn
              Jan 17 '14 at 9:12






            • 1





              given +1...mark it as accepted too!! :)

              – NoobEditor
              Jan 17 '14 at 9:14











            • This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

              – Jukka K. Korpela
              Jan 17 '14 at 10:58











            • @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

              – TheGeekZn
              Jan 17 '14 at 11:14
















            0












            0








            0







            The following .css code provides the template for the attached picture:



                table {
            display: table;
            width: 100%;
            table-layout: fixed;
            position: absolute;
            top: 10px;
            empty-cells: hide;
            }

            td.small:first-Child {
            vertical-align: top;
            width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            }

            td.small:last-Child {
            vertical-align: top;
            width: 95px;
            }

            td.extend {
            vertical-align: top;
            word-wrap: break-word;
            }

            .userName a {
            color: #9DC8FC;
            }




            <tr>
            <td class="small userName">
            <a title="Administrator" href="#">Administrator</a>
            </td>
            <td class="extend">
            is it me you're looking for?
            </td>
            <td class="small">
            10:14:01 AM
            </td>
            </tr>


            Chatbox






            share|improve this answer













            The following .css code provides the template for the attached picture:



                table {
            display: table;
            width: 100%;
            table-layout: fixed;
            position: absolute;
            top: 10px;
            empty-cells: hide;
            }

            td.small:first-Child {
            vertical-align: top;
            width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            }

            td.small:last-Child {
            vertical-align: top;
            width: 95px;
            }

            td.extend {
            vertical-align: top;
            word-wrap: break-word;
            }

            .userName a {
            color: #9DC8FC;
            }




            <tr>
            <td class="small userName">
            <a title="Administrator" href="#">Administrator</a>
            </td>
            <td class="extend">
            is it me you're looking for?
            </td>
            <td class="small">
            10:14:01 AM
            </td>
            </tr>


            Chatbox







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 17 '14 at 8:21









            TheGeekZnTheGeekZn

            1,68763368




            1,68763368













            • so this is the answer??? :)

              – NoobEditor
              Jan 17 '14 at 8:35











            • For me it is... If you want your table looking like that, then yes :)

              – TheGeekZn
              Jan 17 '14 at 9:12






            • 1





              given +1...mark it as accepted too!! :)

              – NoobEditor
              Jan 17 '14 at 9:14











            • This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

              – Jukka K. Korpela
              Jan 17 '14 at 10:58











            • @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

              – TheGeekZn
              Jan 17 '14 at 11:14





















            • so this is the answer??? :)

              – NoobEditor
              Jan 17 '14 at 8:35











            • For me it is... If you want your table looking like that, then yes :)

              – TheGeekZn
              Jan 17 '14 at 9:12






            • 1





              given +1...mark it as accepted too!! :)

              – NoobEditor
              Jan 17 '14 at 9:14











            • This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

              – Jukka K. Korpela
              Jan 17 '14 at 10:58











            • @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

              – TheGeekZn
              Jan 17 '14 at 11:14



















            so this is the answer??? :)

            – NoobEditor
            Jan 17 '14 at 8:35





            so this is the answer??? :)

            – NoobEditor
            Jan 17 '14 at 8:35













            For me it is... If you want your table looking like that, then yes :)

            – TheGeekZn
            Jan 17 '14 at 9:12





            For me it is... If you want your table looking like that, then yes :)

            – TheGeekZn
            Jan 17 '14 at 9:12




            1




            1





            given +1...mark it as accepted too!! :)

            – NoobEditor
            Jan 17 '14 at 9:14





            given +1...mark it as accepted too!! :)

            – NoobEditor
            Jan 17 '14 at 9:14













            This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

            – Jukka K. Korpela
            Jan 17 '14 at 10:58





            This sets a fixed width on the first column, not the width of longest name, and it truncates its content. See what happens if you add the row <tr><td>Supercalifragilistic<td>foo<td>bar.

            – Jukka K. Korpela
            Jan 17 '14 at 10:58













            @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

            – TheGeekZn
            Jan 17 '14 at 11:14







            @JukkaK.Korpela You have a point! In my original post, I said up to a max (Which would be whatever size the dev wants it). So this has a max width just in case the name is SuperLongBecauseSomeHaxxorWantsToMakeHeadaches :D

            – TheGeekZn
            Jan 17 '14 at 11:14




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21179718%2fhtml-table-with-variable-fixed-and-remaining-width%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma