Asp:CheckBox checkbox and text are not on the same line

I can’t seem to figure out how to get the checkbox and associated text to appear on one line. The text is very short so it doesn’t seem to be a width issue.
I tried setting display:inline on the control but when it’s rendered, a span is added around the input and label and that has the display:inline.
If I manually add the display:inline, using the resources view in Chrome, to the resulting label than it’s fine. The problem is I don’t know how to get the control to do this.

Thanks.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You want to have display:inline applied to the <label> element that ASP generates to hold the label text, not the control itself. So, for example:

<style type="text/css">
    label { display: inline-block; }
</style>
<asp:CheckBox Text="This text appears on same line as checkbox" runat="server" />


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x