How can I apply horizontal align to <label>
element? If I do this <label><p>3</p></label>
everything works fine. I don’t understand why <p>
element has auto margin (centred) when <label>
is not.
html
body {
background: #2b2b2b;
font-size: 36px;
font-family: Helvetica neue, roboto;
color: white;
}
.main {
display: flex;
flex-wrap: wrap;
justify-content: center;
width: 75%;
margin: 0 auto;
background: black;
}
.common {
width: 45%
}
#div1 {
background: purple;
text-align: right;
}
#div2 {
background: orange;
}
#div3 {
background: olive;
text-align: right;
}
#div4 {
background: gray;
}
label {
}
<div class="main">
<div id="div1" class="common">1</div>
<div id="div2" class="common">2</div>
<div id="div3" class="common"><label for="name-label">3</label></div>
<div id="div4" class="common"><p>4</p></div>
</div>