Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

font-family not loading?

Tags:

css

I have the following CSS declaration:

body {font-family: Verdana, Tahoma, "Trebuchet MS", "DejuVu Sans", "Bitstream Vera Sans", sans-serif;

It isn't loading on the page. I'm having to add:

    <style>
body {font-family: Verdana, Tahoma, "Trebuchet MS", "DejuVu Sans", "Bitstream Vera Sans", sans-serif;}
</style>

To the HTML to get it to work...This is true in chrome and safari...this one is weird, thoughts?

Note that all other CSS is working correctly...

like image 949
Mike Earley Avatar asked Jan 17 '13 13:01

Mike Earley


People also ask

How do you force font family?

You could select all the children elements using . parent * and then set font-family to inherit . This will effectively override the child element font and force all children elements to inherit the value of whatever the closest parent element's font is. And if you only want to target the .

How do I know if my font family is loaded?

check() The check() method of the FontFaceSet returns whether all fonts in the given font list have been loaded and are available.

Why are fonts not working in CSS?

Fonts aren't working in mobile browsersThe browser isn't supported. The correct font weight or style isn't specified in the CSS. Add the weight or style to the web project and make sure it is specified correctly in the CSS.


2 Answers

have you tried to select following?

body, body * {
    font-family: Verdana, Tahoma, "Trebuchet MS", "DejuVu Sans", "Bitstream Vera Sans", sans-serif;
} /* this affects every element in the body and the body itself */

/* OR just */
* {
    font-family: Verdana, Tahoma, "Trebuchet MS", "DejuVu Sans", "Bitstream Vera Sans", sans-serif;
} /* this affects every element */

here is what you can do with CSS3: http://www.css3.info/preview/web-fonts-with-font-face/

like image 117
algorhythm Avatar answered Oct 12 '22 21:10

algorhythm


So, !important worked, I'm not sure why. One note, I took out the extra families, it looks like this now:

body, body * {
font-family: Verdana, Tahoma, sans-serif !important;
}

But changing that had nothing to do with fixing it. The !important fixed it. Even though there isn't anything else changing the font-family at any other point in the CSS (refer to the working JS Fiddle). I attached a screenshot of the developer tools to show the inheritance.

developer tools

like image 32
Mike Earley Avatar answered Oct 12 '22 22:10

Mike Earley