September 10, 2013

Labels do not want to center using php

User2747140’s Question:

I am new to php and apologise for the trivial question I’m asking. I can’t seem to get my labels to center align. As you can see from the attachment, only the text box get’s centered. Please could you point me in the right direction?

Here’s the code. As you can see, I use the center at the start and the end of my form.

echo"   <center>    <fieldset>
        <div class="form-horizontal">
             <h7 class="label"><font color="#FF0000" size="+1"><strong>* </strong></font>: Required Fields</h7> <br><br>
            <div class="form-row">
            <div class="form-label">First Name <font color="#FF0000" size="+1">*</font><em></em></div>
                <div class="form-controls">
                   <input id="First Name" type="text" name="FirstName" value="$firstname">       
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">Last Name <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                    <input id="Last Name" type="text" name="LastName" value="$LastName">      
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">ID Number <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                  <input name="IDNumber" type="text" id="ID Number" value="$IdentityNumber" maxlength="13">       
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">Email Address</em></div>
                <div class="form-controls">
                   <input id="Email Address" type="text" name="EmailAddress" value="$ParentEmailAddress">             
                </div>
                </div>


                <div class="form-row">
                <div class="form-label">Mobile Number <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                     <input name="MobileNumber" type="text" id="Mobile Number" value="$ParentMobileNo" maxlength="10">         
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">Date of Registration <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                    <input id="Date of Registration" type="text" name="DateofRegistration" value="$DateOfRegistration">      
                </div>
                </div>


                <div class="form-row">
                <div class="form-label">Learners Full Name <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                   <input id="Learners Full Name" type="text" name="LearnersFullName" value="$LearnerFullName">       
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">Learners Date of Birth <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                   <input id="Learners Date of Birth" type="date" name="LearnersDateofBirth" value="$LearnerDOB">    
                </div>
                </div>

                <div class="form-row">
                <div class="form-label">School Nominated <font color="#FF0000" size="+1">*</font></div>
                <div class="form-controls">
                <select id="School Nominated" type="text" name="SchoolNominated">
                    </center>";

I have tried adding a picture to show you the form. Please go to this link to view it (http://i.stack.imgur.com/lIAFG. png)

Use CSS, not PHP to center text. The following will center all the labels.

label { text-align: center; }

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!