Issue with the usage of <div>
elements
Everything runs smoothly: Text "Whatever" appears in column 1, followed by a radio button:
No issues here (text without a radio button):
The cell immediately following the text "Whatever" should display in column 1 of the next row rather than directly below the text.
Context:
The table structure is generated by my HTML helper, which creates ASP.NET MVC2 code to present radio buttons alongside images within a table layout.
The HTML helper initiates the creation of a table containing five radio buttons organized into two columns and includes one radio button labeled "Whatever." (Additional parameters are involved, but that's not the concern...)
The table is constructed using <div>
tags exclusively (no <table>
tag at all!). I apply styles like "width: 50%;" for tables featuring two columns and use "float: left;" as well.
Everything functions properly until the radio button with only text (without any image) needs to be displayed in the last column. For instance, refer to picture 2: The radio button following the "text radio button" should appear in the first column after it, NOT underneath the text.
What am I doing incorrectly?
Further details: Same behavior noted in both IE and Firefox browsers.
Thank you for the prompt response! As requested:
<div id="stars" style="width: 860px; border: solid 2px #000000; background-color:#CCCCCC;" >
<div id="div0" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix0" type="radio" text="6" value="false" />
<label for="idPrefix0">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="6" >
</label>
</div>
<div id="div1" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix1" type="radio" text="2" value="false" />
<label for="idPrefix1">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="2" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="2" >
</label>
</div>
<div id="div2" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix2" type="radio" text="5" value="false" />
<label for="idPrefix2">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="5" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="5" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="5" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="5" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="5" >
</label>
</div>
<div id="div3" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix3" type="radio" text="1" value="false" />
<label for="idPrefix3">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="1" >
</label>
</div>
<div id="div4" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix4" type="radio" text="4" value="false" />
<label for="idPrefix4">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="4" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="4" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="4" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="4" >
</label>
</div>
<div id="div5" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix5" type="radio" text="-1" value="false" />
<label for="idPrefix5">
Whatever
</label>
</div>
<div id="div6" style="width: 50.0%; float: left;" >
<input name="radioButtonName" id="idPrefix6" type="radio" text="3" value="false" />
<label for="idPrefix6">
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="3" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="3" >
<img src="/Content/Images/Dialog/gold_star.png" style="width: 16px; height: 17px;" alt="3" >
</label>
</div>
<div id="div7" style="width: 50.0%; float: left;" >
 
</div>
</div>
Puzzling situation (initially):
Easily explained: Visualize a chain effect where the cell/radio button with the 5 images shifts "two positions/columns to the right" (its correct placement), causing subsequent cells/radio buttons to follow suit. This would result in everything being appropriately positioned. ;-)