CSS Treehouse Club: CSS My First Web Page Color Keywords, Hex Colors, and Font Families

Che Hei Cheung
Che Hei Cheung
1,438 Points

Do I have to make font changes in both html and css? It seems that only changing in css will change the fonts

I have made changes of fonts on html, but no effects. Only making changes on css will have the effect. Why is that?

2 Answers

Jennifer Nordell
MOD
Jennifer Nordell
Treehouse Moderator

Hi there! Alexander Davison is correct. HTML is the structure of your document. CSS is the styling of your document. So HTML simply defines the elements to be rendered on the page and the general attributes that don't necessarily have to do with styling. The src and alt attributes are good examples of these.

However, it's also possible to include "in-line" CSS in the HTML or even a <style> section that contains CSS inside the HTML document. Most often, though, we link to an external file. The question here then would be, how did you implement the font sizes in the HTML document you were working on?

We'd need to see your code to tell you why an in-line style might not be working. It should, as the specificity would have a higher priority than any linked documents or anything in the <style> element.

Hope this helps! :sparkles:

Che Hei Cheung
Che Hei Cheung
1,438 Points

Thanks Jennifer! this is the html code: <link href='https://fonts.googleapis.com/css?family=Indie+Flower' rel="stylesheet" type="text/css">

and this is the css code: font-family: 'Indie Flower', cursive;

it seems that even I do not write the html code, I can still get the font style I choose. So why the course teacher still write the html code?

Jennifer Nordell
Jennifer Nordell
Treehouse Moderator

My best guess would be that it's loading in cached data from your browser when you remove the HTML link to the font style. Otherwise, it would revert to the browser default. But if you need a font outside of the defaults and system fonts, you're going to need a link to it in the HTML in some way.

HTML isn't for doing things like changing fonts, changing colors, changing sizes, etc., HTML is used for making the bare bones of a site. For example, you should use HTML to add text to a website, and you should use CSS to change the color of that text.

Good luck! ~Alex