FAQ: CSS Typography - Font Family

This community-built FAQ covers the “Font Family” exercise from the lesson “CSS Typography”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn CSS

FAQs on the exercise Font Family

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

For this lesson, on line 5, why is the font-family, Arial, in quotations, ie,

  1. font-family: “Arial”, sans serif;

The instructions indicate that one-word font-families don’t have quotations, and the exercises marked me as wrong when I initially tried, eg,

font-family: “Georgia”;

rather than

font-family: Georgia;

Thanks!

2 Likes

probably because it’s followed by a coma and then sans-serif;
It’s not just 1 font

1 Like

I’m not sure that’s it javapro91079. The specified font-family florafinching is referring to is under the html root element, not a paragraph or heading element.

Interestingly, the “Arial” value of the font-family property, is highlighted in yellow, as are the other type-face, how ever the sans-serif without the double quotes is purple.

I’m guessing this is something to do with the syntax of the font-family property.

I found this: https://css-tricks.com/almanac/properties/f/font-family/
Which helps explain why there are two font-types separated by a comma and at the end might help explain why the Arial is in double quotes.

Although you can write single-worded font-family value without double quotes, the same is not true for multiple-worded values. For example, to set the font-family property of the body selector to cursive, you can use the following rule:

body {
   font-family: cursive;
}

To set it to Courier new, you would need the following rule:

body {
   font-family: "Courier new";
}

The quotation marks wrapping Arial can easily be omitted with no errors. Font families which consist of one word can be enclosed in quotation marks but don’t need to. Font families which consist of multiple words must be enclosed in quotation marks

Whatever option you choose, you must stay consistent. This means that if you choose to wrap single-worded font families in quotation marks, keep doing so throughout your stylesheet

1 Like

No. Arial, sans-serif simply means set the font family of the element to Arial. However, if a user doesn’t have the Arial font installed on his machine, set the element’s font family to sans-serif

The only reason Arial is highlited in yellow is because it is a string. Codecademy decided to highlight strings in yellow. This is called color coding. It simply improves readability

What is the difference between something like sans-serif and Helvetica? I’ve heard that sans-serif is a font family while Helvetica is a font belonging to the sans-serif font family. Is that right?

No one has answered why CC marks you wrong for using quotes around single-word font families.

I tried using quotes around a personal project of mine and it works fine. It must be CC that doesn’t like it

Forgive me if I use the wrong terminology, but when it comes to the CSS properties, is there an order that needs to be followed.

In lesson 1 for typology I added “font-family: Georgia;” to the end of the properties that were already used and it was marked wrong. All I did was cut/paste the line to the top(first after " h1 { " ), and now its marked correct. Why?

ok… I did lesson two today and it did the opposite. I added the code at the top and it was marked wrong, I move at to the bottom and its correct!

Same thing happened to me, it’s confusing as to why it marks it wrong but may be just a bug. There shouldn’t be an order as to where we add the properties. I usually group my properties by type. for example, I group the colors near each other (background-color, color) and font properties near each other (font-family, font-size, font-weight).

The third instruction in the lesson is the following:

In style.css , use a font stack to give the .editorial elements fallback fonts of Times New Roman and serif

However, the previous instruction was to change the font family to a sans-serif font:
In style.css , change the font family of the .editorial elements to Trebuchet MS .

So wouldn’t it make sense for the fallback fonts to be a list of similar-looking sans-serif fonts?

Because CodeAcademy glitches sometimes. If you put Serif in quotes it gives you an error, but if you don’t put Georgia in quotes it gives you an error as well, and they’re both single words. I came looking for this same question, thank you.

If that’s not available, it will try to use a similar font, Georgia. And if Georgia is not available, it will try to use Times New Roman.

Well as a developer I am using FOSS… All these fonts are restricted fonts. So someone on Linux, FreeBSD or whatsoever will def. not have those fonts… Wouldn’t it be better to always put (for this matter) ‘serif’ at the end? This should have been a part of the lesson!

So is there a way to create a unique font using what software?

I think it’s purple because it’s a keyword used if none of the other specified font families are available.

How do I know which fonts use a quotation marks around it and which do not?

The use of quotation marks around font names depends on the context in which you are using the fonts, particularly in CSS (Cascading Style Sheets) for web design. Here are the general rules:

  1. Font names with spaces or special characters: If the font name contains spaces, numbers, or special characters, you should enclose it in quotation marks.
font-family: "Times New Roman", Arial, sans-serif;
  1. Single-word font names: If the font name is a single word without any spaces or special characters, you can omit the quotation marks.
font-family: Arial, Helvetica, sans-serif;
  1. Font names with keywords: If the font name matches a CSS keyword (like inherit, serif, sans-serif, monospace, etc.), you should enclose it in quotation marks to avoid conflicts.
font-family: "Comic Sans", "Courier New", monospace;

Example

  • With Quotation Marks:
font-family: "Open Sans", "Helvetica Neue", sans-serif;
  • Without Quotation Marks:
font-family: Arial, Verdana, sans-serif;

Hi !

Is it possible to chose between serif and sans serif for any font ? Or does the font have to be specially designed as serif and/or sans serif ?

Thanks