I took a CSS quiz at w3schools.com, and I got all of the answers correct except the one below. I tried to search on the subject, but as far as I can see the answer should be correct. Where am I wrong? Really confused with this.
15. Which property is used to change the font of an element?
You answered:
font-family
Wrong Answer!
The font
property is the one that changes all aspects of a font, including family, style and weight. The font-family
property only changes the font-family. The family is a group of related fonts (or typefaces).
So 'Comic Sans MS' is a font family, while 'Comic Sans MS Bold 10pt' is a font. In speech, people tend to mix up those terms.
font
and font-family
do different things:
Best illustrated with an example. Arial is a font family. Arial Bold 14 point is a type font. Helvetica is a font family. Helvetica Ultra Compressed 26 point is a type font.
The quiz says that the correct answer is that both font-family
and font
can be used to set the font. This can be characterized as correct, when the other options are font-family
alone and font
alone. This question, and the quiz in its entirety, is not as seriously wrong as much of w3schools content (see http://w3fools.com), just largely pointless and inaccurate.
The font-family
property sets, as the name suggests, the font family alone. The font
shorthand sets all normally settable font properties and also line height. The interpretation of the question revolves around the question “what is a font?” If you mean font family, then font-family
sets that only, whereas font
also sets font size, font weight, etc. If you mean a specific typeface in a specific size, specific weight etc., then only font
does that.
15. Which property is used to change the font of an element?
You answered:
font
Wrong Answer!
Basically the correct answer is both of them (font anf font-family)