Click here to Skip to main content
13,251,760 members (32,984 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I wanted to add the Brainyquote Nature Quote Of The Day: Javascript Feed on my website, so that it could automatically change by itself every day, but I didn't know how to change the font. This is the code that I had to copy/paste into my webpage:

<script type="text/javascript" src="https://www.brainyquote.com/link/quotena.js"></script>
<small><a href="https://www.brainyquote.com/quotes/topics/topic_nature.html" target="_blank" rel="nofollow">more Nature Quotes</a></small>


//Outputs the quote of today:

Nature Quote of the Day
Read nature; nature is a friend to truth.
Edward Young
more Nature Quotes

What I have tried:

I wanted to change the font to Merriweather, so I tried using google fonts, and inserting it in the standard way,but it didn't change the font. So where am I supposed to put this link?
Posted 8-Nov-17 5:22am
Updated 9-Nov-17 10:16am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hello,

You need to apply the font you loaded to the quote of the day area of the page using CSS:

There are different ways of applying CSS, below is one way, highlighted in bold text:

<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
 
<div style="font-family: 'Merriweather', serif;">
<script type="text/javascript" src="https://www.brainyquote.com/link/quotena.js"></script>
<small><a href="https://www.brainyquote.com/quotes/topics/topic_nature.html" target="_blank" rel="nofollow">more Nature Quotes</a></small>
</div>


This encloses the quote of the day in a HTML <div> tag and then applies the Merriweather font to its content.
  Permalink  
Comments
Member 13502831 9-Nov-17 4:36am
   
but is the style tag important here? I mean aren't the div and link tag enough? Thanks :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Yes the style attribute is important. The link just loads the font so it can be used on the page. You have to then apply the font.

Please see the following which gives a better example:

Get Started with the Google Fonts API
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 9 Nov 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100