Search code examples
htmlcsscss-tables

min-width property doesn't work on Div, but works on Table tag


I have a div in my page. I set it's width to 500px. but sometimes it's content get space more than 500px. so I set it's min-width property to 500px. it expect that is takes 500px by default and take longer according to it's content. but it takes whole of the page's width by default.

But if I replace the Div by a Table, it works correctly. Does anybody know the reason?


Solution

  • Please see the demo.
    Demo.

    You have to set in css like

       min-width: 200px;
       width: auto;
       float: left;