Interview Q&A · questions with model answers

HTML & CSS Interview Questions

Part of the study plan for: Frontend Engineer · Full Stack Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. How do you safely display user-generated content in HTML?

    Treat it as text: escape it on the server or insert it with textContent, never innerHTML. If users may submit rich HTML, sanitise it with a well-maintained allow-list sanitizer such as DOMPurify,…

  2. How do you make an HTML table accessible, and when shouldn't you use a table?

    Give it a caption, use th for header cells with scope="col" or scope="row", and group rows with thead and tbody. Use tables only for tabular data, never for page layout.

  3. How do you add video with captions in HTML5?

    Use video with controls, one or more source elements in different formats, and a track element with kind="captions" pointing to a WebVTT file, plus fallback content.

Was this page helpful?

Report a mistake