S Nash
S Nash

Reputation: 2499

Make Html Label show on right side of Div element

I have a DIV element:

<div style="background-color:red">This is a test
    <label>ID:</label>
    <asp:TextBox runat="server"><asp:Textbox>
</div>

I need to show "This is a test" on left side but the Label and Textbox on the right side of the side.

I tried

margin:right 0px;

but this did not help.

Also tried Float:right but this created strange results.

Upvotes: 4

Views: 8807

Answers (2)

Jared Dykstra
Jared Dykstra

Reputation: 3626

Add a div to wrap the label and input, and use float:

.input-group {
    float: right;
}
<div style="background-color:red">This is a test
  <div class="input-group">
    <label>ID:</label>
    <input type="text" />
  </div> 
</div>

Upvotes: 3

NoAnOld
NoAnOld

Reputation: 171

You can try using float:right; in your style:

<div style="background-color:red">This is a test
    <div style="float:right">
        <label>ID:</label>
        <asp:TextBox runat="server"><asp:Textbox>
    </div>
</div>

Upvotes: 0

Related Questions