Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:10:45+00:00 2026-05-23T16:10:45+00:00

I have this grid: If I change the tables width from 100% to auto,

  • 0

I have this grid:

enter image description here

If I change the tables width from 100% to auto, table collapses horizontally.

enter image description here

Which is not desirable. How can I make the table columns (td elements) shrink automatically to fit their content, while at the same time, the table, and tr elements fill the entire space of their parent?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:10:46+00:00Added an answer on May 23, 2026 at 4:10 pm

    How can I make the table columns (td elements) shrink automatically to fit their content, while at the same time, the table, and tr elements fill the entire space of their parent?

    <table> and <tr> elements are as wide as the <td> elements inside of them. You can’t have every <td> be as small as its contents and have the table as a whole be as wide as the space available, because the table can only be as wide as the cells inside it.

    (i.e. unlike most HTML elements, <table> elements can’t be sized independently from their contents.)

    You can set one cell to be as wide as possible though, by giving it a width of 100%:

    <table style="width: 100%; background: grey; color: white;">
         <tr>
             <td style="background: red;">Content</td>
             <td style="background: green;">Content</td>
             <td style="background: blue; width: 100%;">Content</td>
         </tr>
    </table>
    

    See http://jsfiddle.net/9bp9g/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code right now to get the row value from jquery grid..
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I'm having a small problem. I have this grid with a column: <data:DataGrid ColumnHeaderStyle={StaticResource
I have this: <ListBox x:Name=PART_lstAttributes Grid.Row=1 Style={StaticResource GlossyBlackListBox}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock x:Name=txtAttributeName Text={Binding
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have something like this in my xaml: <Grid> <Image Name=image Source=../../Images/DefaultImage.png HorizontalAlignment=Stretch VerticalAlignment=Stretch></Image>
I have a Grid inside a Canvas defined like this: <Canvas x:Name=outerCanvas> <Grid Grid.Row=1
I have a grid in a XAML file in a WPF project. This MainGrid
We have two textBlocks like this: (we used .NET FW 3.0) <TextBlock Grid.Column=0 Name=tabName
I have a weird grid with different height columns. By this I mean, column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.