By adding this to your .rectangle
class
display: flex;
justify-content: center;
align-items: center;
Sample snippet
body {
background-color: black;
}
.rectangle {
width: 125px;
height: 125px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
h3 {
color: #fff;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="rectangle">
<span><i class="fa fa-quora" aria-hidden="true" style="font-size: 75px;" align="center"></i></span>
</div>
<h3>Quora</h3>
If you want to support older browsers, add this to your .rectangle
class
display: table-cell;
text-align: center;
vertical-align: middle;
Sample snippet
body {
background-color: black;
}
.rectangle {
width: 125px;
height: 125px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background-color: #fff;
display: table-cell;
text-align: center;
vertical-align: middle;
}
h3 {
color: #fff;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="rectangle">
<span><i class="fa fa-quora" aria-hidden="true" style="font-size: 75px;" align="center"></i></span>
</div>
<h3>Quora</h3>