css question, please help
I know this is not the right place to ask for a CSS help, but it's an active good forum and my question is simple.
I just want to know why does an element take up the entire width when I set the width?
For example,
- <div style="width:50px;">
-
- <fieldset>
- <legend>test A</legend>
- <table>
- <tr>
- <td><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </td><td>
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td>
- </tr>
-
- </table>
-
- </fieldset>
- </div>
- <div style=" width:300px; float:left;">
- <fieldset><legend>test2</legend>
- <table>
- <tr>
- <td><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </td><td>
- <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td>
- </tr>
- </table>
- </fieldset>
- </div>
When I check through chrome developer's tools, I can see that the second table cannot float right next to the first table or the first div, because the first div is taking up the entire place though I limited the width. I know if used float:left in the first dive, both divs will float one after the other. But I want to know why does using width is not enough to do the trick?
Can someone please explain that to me?