Questions
13 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)?
13 / 30

How does accessibility relate to text formatting in HTML?

Difficulty: 5/10
semantic HTML, color contrast, responsive typography

Accessibility and Text Formatting in HTML & CSS

Accessibility ensures that all users, including those using screen readers or other assistive technologies, can understand and navigate content. Text formatting plays a role in conveying meaning and emphasis in a way that is both visually and semantically correct.

Best Practices for Accessible Text Formatting
  1. 1

    Use semantic HTML tags like <strong>, <em>, <h1>-<h6>, <p> instead of purely visual tags like <b> or <i>.

  2. 2

    Combine CSS properties like font-weight or font-style with semantic tags to style text without losing meaning.

  3. 3

    Avoid using color alone to convey information; ensure sufficient contrast for readability.

  4. 4

    Use relative units (em, rem) for font sizes to respect user preferences and browser zoom settings.

  5. 5

    Maintain proper line-height and spacing to improve readability for all users.

Example: Accessible Emphasis

In this example, <strong> conveys meaning to assistive technologies while CSS font-weight and color enhance visual emphasis. Users relying on screen readers receive the semantic information without relying on visual styling alone.

Key Takeaways
  1. 1

    Semantic HTML ensures accessibility while CSS enhances visual presentation.

  2. 2

    Avoid using <b> or <i> solely for styling; they lack semantic meaning.

  3. 3

    Proper contrast, spacing, and scalable font sizes improve readability for all users.

  4. 4

    Combining CSS with semantic HTML strikes a balance between design and accessibility.

Scenario Questions

0-2 years experience

  1. 1You need to style a paragraph so its font size respects the user's browser default and can be resized with browser zoom. How would you write the CSS?
  2. 2If you set a heading's color to #777 on a white background, what accessibility issue might arise and how would you fix it using CSS?
  3. 3How do you ensure that bold text used for emphasis remains readable by screen readers?

2-5 years experience

  1. 1We have a component where the text color is defined in a CSS variable that changes with a dark‑mode toggle. Users report insufficient contrast for low‑vision users. Walk me through how you'd investigate and resolve this.
  2. 2A client’s legacy HTML uses <b> tags for emphasis and inline style attributes for colors. They want WCAG AA compliance without rewriting all markup. What CSS strategy would you propose?
  3. 3During QA a screen reader reads a button as "button button" after you added a ::before pseudo‑element for an icon. Why does this happen and how can you adjust your CSS to avoid it?

5-8 years experience

  1. 1Design a reusable design‑system token for typography that enforces accessible line‑height, font‑size scaling, and color contrast across multiple products. What CSS techniques and tooling would you include?
  2. 2Our web app dynamically injects user‑generated markdown that can contain arbitrary HTML. How would you safeguard text formatting to stay accessible while preventing style leakage?
  3. 3Explain the trade‑offs between using relative units (rem, em) versus clamp() for responsive, accessible typography on a high‑traffic site.

8+ years experience

  1. 1We are planning a company‑wide migration from a legacy CSS framework that hard‑codes colors to a new accessible design system. How would you orchestrate the rollout to ensure text contrast and semantic markup stay compliant across dozens of teams?
  2. 2At scale, how do you measure and enforce accessibility compliance for text formatting across thousands of pages, and what role does CSS play in that pipeline?
  3. 3Discuss how you’d balance performance (critical CSS size) with the need to provide multiple high‑contrast themes for users with different accessibility needs.

Follow-up Questions

  • Can you show a CSS snippet that guarantees minimum contrast?
  • What automated tools would you run to verify your solution?
  • How do you handle edge cases like high‑contrast OS settings?
Share

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