When using the universal selector *
, it applies styles to all elements on a page. For example, applying the font family Algerian:
*{
font-family:Algerian;
}
However, this can cause issues when using icon fonts like FontAwesome, as it overrides their specific font requirements and may hide the icons.
To prevent this, you can utilize the :not
selector. For instance, if you have a FontAwesome icon like
<i class="fa fa-bluetooth"></i>
, you can target elements excluding certain ones:
*:not(i){
font-family:Algerian;
}
This will apply Algerian font style to all elements except those with the tag name <i>
. You can further specify by excluding classes:
*:not(.fa){
font-family:Algerian;
}
Similarly, you can exclude multiple classes by chaining selectors like so:
*:not(i):not(.fa):not(.YourClassName){
font-family:Algerian;
}