Question

I have a registration form in html and I must have label aligned to left and input aligned to right. this is the code:

<form method = "post" action = "registrazione2.php">
        <fieldset>
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Nome:</label>
            <input type="text" name="Nome" value ="<?php echo $nome; ?>" style="position: static;" size="30";/>
        </p><br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Cognome:</label>
            <input type="text" name="Cognome" value ="<?php echo $cognome; ?>" style="position: static;" size="30"; />
        </p><br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Età:</label>
            <input type="text" name="Eta" value ="<?php echo $eta; ?>" style="position: static;" size="30";/>
        </p><br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Sesso:</label>
            <select name = "os"  style="position: static;" >
                <?php 
                if($sesso == "")
                    echo "<option selected = \"selected\">Selezionare sesso</option>";
                else?>
                <option value="Uomo" <? if($sesso == "Uomo") echo "selected = \"selected\";"?>Uomo</option>
                <option value="Donna" <? if($sesso == "Donna") echo "selected = \"selected\";"?>Donna</option>
            </select>
        </p>  <br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Città:</label>
            <input type="text" name="Citta" value ="<?php echo $citta; ?>"style="position: static;" size="30"; />
        </p><br /> 
         <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>CAP:</label>
            <input type="text" name="CAP" value ="<?php echo $cap; ?>" style="position: static;" size="30";/>
        </p> <br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Via:</label>
            <input type="text" name="Via" value ="<?php echo $via; ?>" style="position: static;" size="30";/>
        </p><br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Numero civico:</label>
            <input type="text" name="Civico" value ="<?php echo $civico; ?>" style="position: static;" size="30";/>
        </p> <br /> 

        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Recapito telef. :</label>
            <input type="text" name="Telefono" value ="<?php echo $telefono; ?>" style="position: static;" size="30";/>
        </p> <br /> 
        <p><p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Indirizzo Mail:</label>
            <input type="text" name="Mail" value ="<?php echo $mail; ?>" style="position: static;" size="30"; />
        </p> <br /> 
        <p>
        <p align="right" style="font-size: 15pt; color: #000000"> 
            <label>Password:</label>
            <input type="password" name="Password" style="position: static;" size="30";/>
        </p> <br /> <br /> 
        </fieldset>
        <input type = "reset" id="contact-submit" value = "AZZERA DATI" style="position: static;" />
<input type = "submit" id="contact-submit" value = "CONFERMA" style="position: static;" />

</form>

with those CSS rules I've aligned label to left but input aren't aligned on the right

Was it helpful?

Solution

apply CSS as below:

label{
  float:left;
}
input[type="text"]{
  float:right;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top