Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 96 / 96100%· free preview
Exam Prep2/2

Viva Questions

20 short CSS viva Q&A.

Common CSS Viva Questions and Answers
  1. What is CSS? Cascading Style Sheets — used to style HTML pages.
  2. Latest version? CSS3 (modular — Selectors, Color, Flexbox, Grid, etc. each are sub-specs).
  3. What does cascading mean? Multiple stylesheets / rules cascade together; cascade rules + specificity decide which wins.
  4. Three ways to apply CSS? Inline, internal (<style>), external (<link>).
  5. Box model components? Content, padding, border, margin.
  6. Difference: padding vs margin? Padding is space INSIDE the border; margin is space OUTSIDE the border.
  7. What is specificity? Weight that determines which CSS rule applies — Inline (1000) > ID (100) > class/attr/pseudo-class (10) > element (1).
  8. relative vs absolute vs fixed? Relative — relative to its normal position. Absolute — positioned relative to nearest positioned ancestor. Fixed — relative to viewport.
  9. display: none vs visibility: hidden? none removes from layout; hidden keeps space but invisible.
  10. What's a pseudo-class? Example? Style based on state — :hover, :focus, :nth-child(2).
  11. Pseudo-element? Example? Style a part of an element — ::before, ::after, ::first-line.
  12. What's z-index? Stacking order — higher value sits on top (only works on positioned elements).
  13. Flexbox vs Grid? Flexbox is 1D (row OR column); Grid is 2D (rows AND columns).
  14. What's a media query? @media (max-width: 768px) { ... } — applies styles only at certain viewports.
  15. What is em vs rem? em is relative to parent's font size; rem is relative to root (<html>) font size.
  16. Inline vs block vs inline-block? Inline: flows in text, no width/height. Block: full width, new line. Inline-block: inline placement + accepts width/height.
  17. What does box-sizing: border-box do? Makes width/height include padding + border (more predictable layouts).
  18. What is !important? Forces a rule to override normal specificity. Avoid unless absolutely needed.
  19. What's a CSS variable? --name: value; declared in any selector; used as var(--name).
  20. Three types of CSS units? Absolute (px, cm), relative (em, rem, %, vw, vh), color (#hex, rgb(), hsl()).
AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

Ready to move on?
// example library
Want more hands-on snippets in CSS3?
Browse 1 runnable example · across 1 chapter · short, copy-paste-friendly · grouped by topic
Explore examples
// side-by-side reference
See this in other languages
Compare the same concept across C, C++, Java, and Python — one table, zero tab-switching.
Compare Languages
// feedback.matters()
Did this lesson help you?