0

The text that comes to the right of checkbox comes in two lines. When I use the float:right property the text moves below the checkbox and without this property one lines comes to the right of checkbox and rest starts from below the checkbox

Below is the code snippet with float property:

input[type=checkbox] {
  margin-top: 10px;
  margin-right: 10px;
}

label {
  width: auto;
  float: right;
}
<input type="checkbox" name="optIn" value="Y">
<label for="ext-comp-1035">I would like to receive email from you. By checking the box you agree that you have read the Privacy Policy and Terms of Use</label><br>

Below is the screen when float:right is not used

Below is the screen when float:right is used

Community
  • 1
  • 1
Aks
  • 102
  • 14

2 Answers2

1

Wrap your input & label one container apply flex

<div style="display:flex">
    <input type="checkbox" name="optIn" value="Y" style="margin-right:10px;">
    <label for="ext-comp-1035">I would like to receive email from you. By checking the box you agree that you have read the Privacy Policy and Terms of Use</label>
    </div>
Lalji Tadhani
  • 14,041
  • 3
  • 23
  • 40
1

Try using display: flex; and align-items: center; to get your alignment done easily. Example code :

.d-flex {
  display: flex;
}

.flex-row {
  flex-direction: row;
}

.align-items-center {
  align-items: center;
}

.input-checkbox {
  margin-right: 10px;
}
<div class="d-flex flex-row align-items-center">
<input type="checkbox" name="optIn" value="Y" class="input-checkbox">
<label for="ext-comp-1035">I would like to receive email from you. By checking the box you agree that you have read the Privacy Policy and Terms of Use</label><br>
</div>
Stefan Joseph
  • 545
  • 2
  • 10