1

I'm trying to learn how to line up fields of a form using CSS instead of tables. I'm having a hard time with a CheckBox control. Here's the code:

<html xmlns="http://www.w3.org/1999/xhtml" >

<label for="CheckBox1">CheckBox</label>
<asp:CheckBox ID="CheckBox1" runat="server" />
<br />
<label for="TextBox1">TextBox</label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div>

</div>
</form>

Here's the CSS:

body
{
}

label
{
    width:300px;
    float:left;
}

I'm getting something that looks like this:

CheckBox []

[CheckBox1] TextBox [ ]

Why is [CheckBox1] on the next line?

Here's a pic: alt text

Also, is there a better way to do this?

1
  • 1
    This is going to be controversial, but I use a TABLE for stuff like this. Problem solved. Commented Jan 25, 2010 at 3:53

2 Answers 2

1

It's been a while since I worked on ASP.Net but if I remember correctly, the checkbox control has a property that lets you specify where the text appears (below it or to the side). That may solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

1

[CheckBox1] only appears in design view - if you run the application you will see that it is not there.

[CheckBox1] appears in design view because you have not set the text for the checkbox - it looks like you are using a label instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.