When using the p
tag, it is important to note that it comes with a default margin
value that may need to be reset or adjusted using the align-items
property. Similarly, when working with div
tags, you will observe that elements are aligned based on their top borders by default, which can be changed by utilizing the align-items
property:
.container {
display: flex;
outline: 1px solid orange;
}
.c1 p {
margin: 0;
}
.c2, .c4 {
align-items: center;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<pre>// p with margin: 0</pre>
<div class="container c1">
<i class="material-icons">call</i>
<p>9988998899</p>
</div>
<pre>// p without margin: 0, but align-items:center</pre>
<div class="container c2">
<i class="material-icons">call</i>
<p>9988998899</p>
</div>
<pre>// div without align-items:center</pre>
<div class="container c3">
<i class="material-icons">call</i>
<div>9988998899</div>
</div>
<pre>// div with align-items:center</pre>
<div class="container c4">
<i class="material-icons">call</i>
<div>9988998899</div>
</div>