Quizz

The full text of this chapter, to read or revisit. To practise, do the exercises.

β–Ά Do the exercises

Exercise 1 β€” Proper Font Family Declaration

Which of the following is the correct way to specify Arial as the primary font, with sans-serif as a fallback?

Options
β€’ font-family: Arial, sans-serif;
β€’ font-family: "Arial"; font-family: "sans-serif";
β€’ font-family: Arial + sans-serif;
β€’ font-family: (Arial, sans-serif);

Hint : Remember that multiple font families should be separated by commas, with the preferred font listed first and generic fallback fonts at the end.

Exercise 2 β€” Complete the Font Styling

Complete the CSS to make the heading large, bold, and use a serif font.

Hint : Think about the properties needed to control the size and weight of text, and the appropriate fallback for a serif font.

Exercise 3 β€” Match Text Properties with Their Effects

Match each CSS property with its visual effect:

Items to match
β€’ text-align: center;
β€’ text-decoration: underline;
β€’ text-transform: uppercase;
β€’ font-style: italic;
Definitions
β€’ Centers text horizontally within its container
β€’ Adds a line beneath the text
β€’ Converts all characters to capital letters
β€’ Slants the text to the right

Exercise 4 β€” Line Height Units

Which line-height value is most recommended for maintaining proper spacing across different font sizes?

Options
β€’ line-height: 1.5;
β€’ line-height: 24px;
β€’ line-height: 150%;
β€’ line-height: 1.5em;

Hint : Consider which type of value will scale proportionally when font sizes change, rather than remaining fixed.

Exercise 5 β€” Complete the Link Styling

Complete the CSS to style links as uppercase with no underline and red color when hovered.

Hint : Consider which properties control the underlining of text and the case transformation of letters.

Exercise 6 β€” Match Elements with Their Purpose

Match each HTML element or CSS property with its correct purpose:

Items to match
β€’ <br>
β€’ <hr>
β€’ letter-spacing
β€’ word-spacing
Definitions
β€’ Creates a line break within text
β€’ Creates a horizontal rule (line) to separate content
β€’ Controls the space between characters
β€’ Controls the space between words

Exercise 7 β€” Font Weight Values

Which font-weight value represents a bolder weight than normal but lighter than bold?

Options
β€’ font-weight: 600;
β€’ font-weight: normal;
β€’ font-weight: bolder;
β€’ font-weight: 300;

Hint : Remember that font-weight can use numeric values from 100 to 900, where 400 is normal and 700 is bold.

Exercise 8 β€” Complete the Paragraph Styling

Complete the CSS to create justified paragraph text with increased line spacing.

Hint : Use `text-align` to control the alignment and `line-height` to adjust the vertical spacing between lines of text.

Exercise 9 β€” Match Text Decoration Properties

Match each text-decoration property with its effect:

Items to match
β€’ text-decoration-line: underline;
β€’ text-decoration-style: wavy;
β€’ text-decoration-color: red;
β€’ text-decoration: line-through;
Definitions
β€’ Adds a line beneath the text
β€’ Makes the decoration line wavy instead of solid
β€’ Changes the color of the decoration line
β€’ Creates a strikethrough effect on text

Exercise 10 β€” Responsive Font Size

Which font-size unit is best for creating responsive text that scales with the viewport size?

Options
β€’ font-size: 5vw;
β€’ font-size: 20px;
β€’ font-size: 1.5em;
β€’ font-size: 150%;

Hint : Consider which unit is specifically designed to scale in relation to the viewport (browser window) dimensions rather than parent elements or default sizes.

Exercise 11 β€” Complete the Title Styling

Complete the CSS to make the title appear in uppercase letters and centered alignment.

Hint : `text-transform: uppercase` turns all letters into capital letters, and `text-align: center` aligns the text to the center.

Exercise 12 β€” Match Font Style Properties

Match each CSS code snippet with its visual description:

Items to match
β€’ font: italic bold 16px/1.5 Arial, sans-serif;
β€’ font: small-caps 14px Georgia, serif;
β€’ text-shadow: 2px 2px 4px #000000;
β€’ font-stretch: condensed;
Definitions
β€’ Italic, bold, 16px Arial text with 1.5 line height
β€’ 14px Georgia text with small caps
β€’ Text with a black shadow offset 2px right and down
β€’ Narrower version of the font if available

Exercise 13 β€” Text Alignment Practice

Which CSS rule will center the text inside a heading element?

Options
β€’ text-align: center;
β€’ align-items: center;
β€’ margin: auto;
β€’ justify-content: center;

Hint : `text-align: center;` is the correct way to horizontally center inline content like text.

Exercise 14 β€” Style a Horizontal Rule

Complete the CSS to create a custom horizontal line with a solid color and no default border.

Hint : `border: none` removes the default line style, and `background-color` gives your `<hr>` its new color.

Exercise 15 β€” Match Spacing Properties

Match each spacing property with its purpose:

Items to match
β€’ line-height
β€’ letter-spacing
β€’ word-spacing
β€’ text-indent
Definitions
β€’ Controls the height of each line of text
β€’ Adjusts space between individual characters
β€’ Adjusts space between words
β€’ Sets the indentation of the first line of text

Exercise 16 β€” Web Safe Fonts

Which of the following font-family combinations is most likely to display consistently across different operating systems?

Options
β€’ font-family: Arial, Helvetica, sans-serif;
β€’ font-family: Futura, Avenir, sans-serif;
β€’ font-family: "Codemon Sans", Arial, sans-serif;
β€’ font-family: serif;

Hint : Think about which font combinations include fonts that are widely installed across different operating systems (web-safe fonts).

Exercise 17 β€” Style a Title

Complete the CSS to make the title red and center-aligned.

Hint : `color` changes the text color, and `text-align` adjusts how the text is aligned inside its container.

Exercise 18 β€” Match CSS with Text Effects

Match each CSS rule with the effect it creates:

Items to match
β€’ text-transform: uppercase;
β€’ text-align: center;
β€’ font-weight: bold;
β€’ font-style: italic;
Definitions
β€’ All letters become capital letters
β€’ Text is centered in its container
β€’ Text appears thicker or stronger
β€’ Text is slanted to the right

Exercise 19 β€” Best Line Height Value

Which line-height value creates the most readable text for paragraphs?

Options
β€’ line-height: 1.5;
β€’ line-height: 1;
β€’ line-height: 3;
β€’ line-height: 0;

Hint : A line-height value between 1.4 and 1.6 is generally considered ideal for paragraph text readability, providing enough space between lines without making them too far apart.

Exercise 20 β€” Text Alignment Properties

Complete the CSS to create a card with a centered heading and justified paragraph text.

Hint : Remember that text-align is the property that controls horizontal alignment of text within its container.

Exercise 21 β€” Match Font Size Units

Match each font size unit with its description:

Items to match
β€’ px
β€’ em
β€’ rem
β€’ vw
Definitions
β€’ Fixed size that doesn't scale with user settings
β€’ Relative to the font-size of the parent element
β€’ Relative to the font-size of the root element
β€’ Relative to 1% of the viewport width

Exercise 22 β€” Proper Use of Line Breaks

Which is the most appropriate use of the <br> element?

Options
β€’ Breaking a line in a poem or address
β€’ Creating space between paragraphs
β€’ Creating a horizontal divider between sections
β€’ Breaking words that are too long

Hint : Think about the semantic purpose of <br> - when is it appropriate to force a line break within a block of text?

Exercise 23 β€” Style Block Quotes

Complete the CSS to style a blockquote with italics, indentation, and a left border.

Hint : Consider which property controls italic text and which property adds a border only on the left side of an element.

Exercise 24 β€” Match Text Properties with Their Purpose

Match each CSS property with its purpose:

Items to match
β€’ line-height
β€’ text-decoration
β€’ font-weight
β€’ text-transform
Definitions
β€’ Controls spacing between lines of text
β€’ Adds or removes underlines, strikethroughs, etc.
β€’ Controls how bold or light the text appears
β€’ Changes text to uppercase, lowercase, or capitalized

Exercise 25 β€” Font Family Best Practice

Which of the following is the best practice when specifying font families in CSS?

Options
β€’ Include both specific fonts and a generic fallback family
β€’ Only specify one font that all users are likely to have
β€’ Only use generic font families like serif or sans-serif
β€’ Avoid using font-family and rely on browser defaults

Hint : It's best to provide a list of font options, starting with your preferred font and ending with a generic fallback like serif or sans-serif, to ensure text displays properly for all users.

Back to the course