Home >Web Front-end >CSS Tutorial >Why Are My Font Awesome 5 Icons Showing as Squares Instead of Icons?
Font Awesome 5 Pseudo-Element Issue: Squares vs. Icons
In CSS, using pseudo elements to display Font Awesome 5 icons can sometimes result in unexpected squares instead of icons in this article We'll explore the causes of the problem and how to fix them.
Causes of Squares
The resulting square problem is caused by a lack of proper character weight. By default, pseudo elements have a "normal" font weight, which is not suitable for Font Awesome icons that require a "bold" or "900" weight to display properly.
Workaround
To fix this problem Add the following rule to your CSS:
.myClass::after { font-weight: 900; }
This rule will set the font weight of the pseudo element to "900" which will cause the Font Awesome icon to display correctly
Exceptions
Please note that this fix applies only to Font Awesome icons. Icons from other icon sets may require different font weights.
The above is the detailed content of Why Are My Font Awesome 5 Icons Showing as Squares Instead of Icons?. For more information, please follow other related articles on the PHP Chinese website!