%with-tooltip { position: relative; display: inline-flex; justify-content: center; align-items: center; } %with-tooltip::before, %with-tooltip::after { position: absolute; } %with-tooltip::before { padding: 10px; bottom: calc(100% + 5px); text-align: center; white-space: nowrap; content: attr(data-tooltip); // incase you are using text-indent to hide the // text of the element %with-tooltip text-indent: 0; } %with-tooltip::after { content: ''; left: 50%; margin-left: -5px; top: -10px; width: 10px; height: 10px; transform: rotate(45deg); } %with-tooltip::after, %with-tooltip::before { display: none; } %with-tooltip:hover::after, %with-tooltip:hover::before, %with-tooltip:focus::after, %with-tooltip:focus::before { display: block; }