Questions
17 of 30
1How can you centre text vertically and horizontally inside a box?
2What is the use of the white-space property?
3How can you truncate text with an ellipsis (...) in CSS?
4How do you wrap or prevent wrapping of text in a container?
5How do you make text responsive across different screen sizes?
6How do you justify text using CSS?
7What does text-shadow do? Give an example.
8How can you apply multiple shadows to text?
9How do you apply gradients to text in CSS?
10How do you control text overflow in a fixed-width container?
11What is the difference between em, rem, and px when styling text?
12How does font-weight differ from <b> tag in semantic meaning?
13How does accessibility relate to text formatting in HTML?
14What’s the difference between semantic and non-semantic text formatting tags?
15How can you ensure consistent text appearance across different browsers?
16What is the difference between font-style, font-variant, and font-weight?
17What is the role of @font-face in web typography?
18How can you import custom fonts in CSS?
19What’s the impact of using web fonts on performance?
20How can you optimise text rendering for readability?
21How do you make text appear vertically (top-to-bottom) using CSS?
22How do you style only the first letter or first line of a paragraph?
23How do you create a drop cap effect?
24How can you highlight a selected text range dynamically?
25How do you make text glow or have a neon effect using CSS?
26What CSS properties can you use for text animations?
27How can you apply a gradient background only to the text and not the entire element?
28How can you apply different styles to different words in the same line?
29How do you prevent text selection on a webpage?
30How do you implement responsive typography (fluid text size)?
17 / 30

What is the role of @font-face in web typography?

Difficulty: 5/10
custom fonts, font loading performance, cross-browser compatibility

Using @font-face to Include Custom Fonts in CSS

@font-face allows web designers to use custom fonts that are not installed on a user's device. It enables consistent typography across different browsers and devices by loading fonts directly from your server or a CDN.

Key Points About @font-face
  1. 1

    Defines a custom font family and points to the font file source.

  2. 2

    Supports multiple font formats: woff2, woff, ttf, eot, svg for cross-browser compatibility.

  3. 3

    Enables designers to maintain brand identity and design aesthetics with unique typography.

  4. 4

    Works seamlessly with CSS properties like font-weight, font-style, and font-variant.

Example: Using @font-face

In this example, OpenSans is loaded as a custom font. If the font fails to load, the browser falls back to Arial or the default sans-serif font. You can define multiple @font-face rules for different weights and styles of the same font family.

Key Takeaways
  1. 1

    @font-face enables use of custom fonts for consistent design.

  2. 2

    Always provide fallback fonts for reliability.

  3. 3

    Combine with font-weight, font-style, and font-variant to style the font appropriately.

  4. 4

    Supports multiple formats to ensure cross-browser compatibility.

  5. 5

    Essential for branding, creative design, and typography control on the web.

Scenario Questions

0-2 years experience

  1. 1We need to add a custom logo font to a landing page. How would you use @font-face to make it work, and what files would you include?
  2. 2If the custom font you declared isn’t showing up in Chrome but works in Firefox, what could be causing that?
  3. 3What happens if you omit the font-weight descriptor in an @font-face rule?

2-5 years experience

  1. 1You added a new @font-face rule for a web app, but the page load time increased noticeably. How would you investigate and mitigate the impact?
  2. 2During a feature rollout, some users see fallback fonts while others see the intended font. Walk me through how you’d debug the issue.
  3. 3Explain the trade‑offs between using multiple font formats (woff2, woff, ttf) in a single @font-face rule.

5-8 years experience

  1. 1Our design system needs to support dozens of brand fonts across many micro‑frontends. How would you structure @font-face declarations and loading strategy to keep bundle size low and avoid FOUT?
  2. 2We’re considering variable fonts vs separate static font files. How does @font-face change, and what performance or maintenance implications does each approach have?
  3. 3If a third‑party font service is being deprecated, outline a plan to migrate to self‑hosted fonts while ensuring no visual regressions.

8+ years experience

  1. 1At a company level, we want to standardize typography across all products while respecting licensing constraints. How would you design a centralized @font-face management system, including CI/CD, caching, and cross‑team governance?
  2. 2Discuss the long‑term implications of serving fonts from a CDN versus bundling them with each app, especially regarding security, privacy regulations, and global latency.
  3. 3How would you approach a phased migration from legacy bitmap fonts to modern web fonts across a legacy codebase, ensuring backward compatibility and minimal disruption?

Follow-up Questions

  • What metrics would you watch after you change the font loading strategy?
  • Can you give an example of a fallback stack you’d use for a brand font?
  • How do you ensure you stay compliant with font licensing when self‑hosting?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.