well aligning input controls

Posted on 2011-04-26
Last Modified: 2012-05-11
Hello all,

This sounds like a basic question but I have been playing with for a while and not able to sort it. I have a submission form with few labels and corresponding text boxes. And I have not been able to align it.

Hiow can I well align it?

Follwoing is my small code snippet:

 <div id = "LabelContainer" style = "width:130px; float:left; height: 216px;">
       <asp:Label ID="LabelSiteName" runat="server" Text="Site name"></asp:Label><br />
       <asp:Label ID="LabelCampainName" runat="server" Text="Campaign Name:"></asp:Label><br />
       <asp:Label ID="LabelStartDate" runat="server" Text="Start Date::"></asp:Label><br />
       <asp:Label ID="LabelEndDate" runat="server" Text="End Date:"></asp:Label><br />
       <asp:Label ID="LabelRulesAudio" runat="server" Text="Audio Rules"></asp:Label><br />
       <asp:Label ID="LabelTextRules" runat="server" Text="Text Rules"></asp:Label><br />
       <asp:Label ID="LabelWebrules" runat="server" Text="Web Rules"></asp:Label><br />
       <asp:Label ID="LabelLockOutLimit" runat="server" Text="LockOut Limit"></asp:Label><br />
       <asp:Label ID="LabelLockOutBit" runat="server" Text="LockOut Bit"></asp:Label><br />
       <asp:Label ID="LabelSpinRules" runat="server" Text="Spin Rules"></asp:Label><br />

    <div id = "InputController" style = "width:200px; float:left">

        <asp:DropDownList ID="DdlSiteName" runat="server" DataSourceID="DsSiteList"
            DataTextField="Desc_nvch" DataValueField="Site_ID_inc">
        <br />  
    <asp:TextBox ID="TextCampaignName" runat="server"></asp:TextBox>
    <br />  
    <asp:TextBox ID="TextStartDate" runat="server"></asp:TextBox>
    <br />    
    <asp:TextBox ID="TextEndDate" runat="server"></asp:TextBox>
    <br />      
    <asp:TextBox ID="TextRulesAudio" runat="server"></asp:TextBox>
    <br />    
    <asp:TextBox ID="TextTextRules" runat="server"></asp:TextBox>
    <br />      
    <asp:TextBox ID="TextWebRules" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextLockOutLimit" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextLockOutBit" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextSpinRules" runat="server"></asp:TextBox>

As you can see lables are not particularly going well with the text boxes and looks  really bad/ You can actually suggest me completely different lay out since I am new to CSS there are high chances that I am missing some rich features which could easily fix this problem
Question by:TheCommunicator
    LVL 9

    Expert Comment

    can you please a sample screenshot ?

    Author Comment

    As you can see here, with the same number of lables and textboxes....lables are not hand in had with the corresponding text box because they are not evenly distributed.
    LVL 9

    Accepted Solution

    The easiest way to go there would be a regular table layout with two columns


    <table cellpadding="0" cellspacing="0" style="border-right: #000000 thin solid; border-top: #000000  id="mytbl">

    LVL 12

    Assisted Solution

    by:Dean OBrien
    or add something like this at the top:

    #LabelContainer label {width:200px;height:50px;display:block}
    #InputController TextBox {width:200px;height:50px;display:block}
    #InputController DropDownList {width:200px;height:50px;display:block}

    You would need to remove the height attribute from this line:
    <div id = "LabelContainer" style = "width:130px; float:left; height: 216px;">


    Author Comment

    Thank you so much . Both approach worked but I took up the one with rable though :).

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now