Search code examples
htmlcssfont-awesome-5

Some FA icons are displayed in FF, Chrome and Safari, but no browser displays them all


I'm using a template from Pixelarity (https://pixelarity.com/ethereal) where they implemented font awesome v4. Since I'd like to use 'brands' as well, I needed to hook up v5.

After trying to combine the FA v5 CSS with the template's CSS it broke somehow (I'm not a CSS-Pro).

In particular, there is a grid of six circles and each of them contains an icon. Firefox displays five of them, Chrome displays three of them and Safari only shows one icon. There are several smaller icons (social media) on that site as well and only Firefox is able to display them properly.

I really ran out of ideas and I hope some of you is able to help me.

Imho, it is not helpful right now to provide all of my code since it is visible through developer tools in browsers as well, am I right? Please let me know if anybody needs specific lines out of my *.css or *.html

Thank you very much in advance.

All the best from Germany, Marcel

EDIT:

I did as suggested. Tried to troubleshoot and reproduce where the mistake might be using my local apache (Mamp on a mac). I'm afraid I still don't have any explanation, but at least I found kind of a pattern in the browser's behavior.

With my fontawesome.css containing the following lines, it works

  • like a charm in firefox. All icons are displayed properly
  • partly in safari. Only icons out of Font Awesome 5 Brands are displayed
  • partly in chrome. Only icons out of Font Awesome 5 Brands and Font Awesome 5 Free (solid) are displayed
  .sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px; }

.sr-only-focusable:active, .sr-only-focusable:focus {
  clip: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  position: static;
  width: auto; }
@font-face {
  font-family: 'Font Awesome 5 Brands';
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/fa-brands-400.eot");
  src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }

.fab {
  font-family: 'Font Awesome 5 Brands';
  font-weight: 400;  
@font-face 
  font-family: 'Font Awesome 5 Brands';
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/fa-brands-400.eot");
  src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }

.far {
  font-family: 'Font Awesome 5 Free';
  font-weight: 400; 
@font-face 
  font-family: 'Font Awesome 5 Free';
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/fa-regular-400.eot");
  src: url("../fonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-regular-400.woff2") format("woff2"), url("../fonts/fa-regular-400.woff") format("woff"), url("../fonts/fa-regular-400.ttf") format("truetype"), url("../fonts/fa-regular-400.svg#fontawesome") format("svg"); }

.fas {
  font-family: 'Font Awesome 5 Free';
  font-weight: 900; 
@font-face 
  font-family: 'Font Awesome 5 Free';
  font-style: normal;
  font-weight: 900;
  src: url("../fonts/fa-regular");
  src: url("../fonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-solid-900.woff2") format("woff2"), url("../fonts/fa-solid-900.woff") format("woff"), url("../fonts/fa-solid-900.ttf") format("truetype"), url("../fonts/fa-solid-900.svg#fontawesome") format("svg"); }

If I now delete the .fas, .far and .fab, so the code looks like the following, it works

  • partly in firefox. Only icons out of Font Awesome 5 Brands and Font Awesome 5 Free (solid) are displayed.
  • like a charm in safari. All icons are displayed properly.
  • partly in chrome. Only icons out of Font Awesome 5 Brands and Font Awesome 5 Free (solid) are displayed.
.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px; }

.sr-only-focusable:active, .sr-only-focusable:focus {
  clip: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  position: static;
  width: auto; }
@font-face {
  font-family: 'Font Awesome 5 Brands';
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/fa-brands-400.eot");
  src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }

@font-face {
  font-family: 'Font Awesome 5 Free';
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/fa-regular-400.eot");
  src: url("../fonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-regular-400.woff2") format("woff2"), url("../fonts/fa-regular-400.woff") format("woff"), url("../fonts/fa-regular-400.ttf") format("truetype"), url("../fonts/fa-regular-400.svg#fontawesome") format("svg"); }

@font-face {
  font-family: 'Font Awesome 5 Free';
  font-style: normal;
  font-weight: 900;
  src: url("../fonts/fa-regular");
  src: url("../fonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-solid-900.woff2") format("woff2"), url("../fonts/fa-solid-900.woff") format("woff"), url("../fonts/fa-solid-900.ttf") format("truetype"), url("../fonts/fa-solid-900.svg#fontawesome") format("svg"); }

I followed the instructions from fontawesome.com for including the whole font into the page's *.css and also triple checked the paths to the fonts.

Adding a bracket here and chrome works, deleting a bracket there and safari works... I'm totally stuck and have no idea what to do, since I've no clue why three different browsers behave in such a different manner.


Solution

  • I doubt that somebody will be as stupid as I am, but nevertheless I let you know about the mistake in my code.

    Font Awesome consists of three fonts which are free to use.

    • FA Brands
    • FA Regular
    • FA Solid

    In the *.css they are called with @font-face and inside of that they are separated by font-family: <Font Name>.

    If you look at my previous code, every font (brands, regular and solid) is called separatly with an individual @font-face-argument. And that's where the magic happens! Since FA Regular and FA Solid are both part of the family called Font Awesome 5 Free several browsers seem to struggle with finding the correct font if there are two different fonts declared to be in the same family. The reason FA Brands was displayed properly is that its family is called Font Awesome 5 Brands.

    Long story short. Out of

    @font-face {
      font-family: 'Font Awesome 5 Brands';
      font-style: normal;
      font-weight: normal;
      src: url("../fonts/fa-brands-400.eot");
      src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }
    
    @font-face {
      font-family: 'Font Awesome 5 Free';
      font-style: normal;
      font-weight: 400;
      src: url("../fonts/fa-regular-400.eot");
      src: url("../fonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-regular-400.woff2") format("woff2"), url("../fonts/fa-regular-400.woff") format("woff"), url("../fonts/fa-regular-400.ttf") format("truetype"), url("../fonts/fa-regular-400.svg#fontawesome") format("svg"); }
    
    @font-face {
      font-family: 'Font Awesome 5 Free';
      font-style: normal;
      font-weight: 900;
      src: url("../fonts/fa-regular");
      src: url("../fonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-solid-900.woff2") format("woff2"), url("../fonts/fa-solid-900.woff") format("woff"), url("../fonts/fa-solid-900.ttf") format("truetype"), url("../fonts/fa-solid-900.svg#fontawesome") format("svg"); }
    

    I made

    @font-face {
      font-family: 'Font Awesome 5 Brands';
      font-style: normal;
      font-weight: normal;
      src: url("../fonts/fa-brands-400.eot");
      src: url("../fonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-brands-400.woff2") format("woff2"), url("../fonts/fa-brands-400.woff") format("woff"), url("../fonts/fa-brands-400.ttf") format("truetype"), url("../fonts/fa-brands-400.svg#fontawesome") format("svg"); }
    
    @font-face {
      font-family: 'Font Awesome 5 Free';
      font-style: normal;
      font-weight: 400, 900;
      src: url("../fonts/fa-regular-400.eot");
      src: url("../fonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-regular-400.woff2") format("woff2"), url("../fonts/fa-regular-400.woff") format("woff"), url("../fonts/fa-regular-400.ttf") format("truetype"), url("../fonts/fa-regular-400.svg#fontawesome") format("svg");
    
      src: url("../fonts/fa-solid-900.eot");
      src: url("../fonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../fonts/fa-solid-900.woff2") format("woff2"), url("../fonts/fa-solid-900.woff") format("woff"), url("../fonts/fa-solid-900.ttf") format("truetype"), url("../fonts/fa-solid-900.svg#fontawesome") format("svg"); }
    

    And now it works like a charm for all browsers.

    Thanks to all your advice and help!

    Have a good one, Marcel