Font Family Open Sans not being used

callmekatootie picture callmekatootie · Apr 7, 2014 · Viewed 64.5k times · Source

I am using Google's Open Sans Font in my application.

I have defined the stylesheet as instructed:

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700'
 rel='stylesheet' type='text/css'>

I then used it on the body selector as:

body {
    font-family: 'Open Sans', sans-serif;
}

I have not defined font family anywhere else. I assume that since I have defined it at the parent, the child elements will automatically inherit it.

However, if I open up the inspector for say an anchor tag in my application and see the computed styles for that tag, I find that (Chrome Latest) the "Rendered Font" says "Times New Roman 18 glyphs" - Is this correct? I was expecting it to say "Open Sans" - Is the Open Sans font not being applied?

Answer

Aalind Sharma picture Aalind Sharma · Oct 20, 2016

Check out the codepen link. Its working fine for me !

.open-sans-font{
  font-family: 'Open Sans', sans-serif;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700" rel="stylesheet">

<div class="open-sans-font">
   Stackoverflow rocks !!!
</div>