🌍 Front-end Web Development · subject

Front-end Web Development CSS Syllabus

The CSS syllabus for Front-end Web Development in full: 3 chapters and 9 topics, every one listed below, plus 50 CSS flashcards with answers.

3Chapters
9Topics
50Flashcards

CSS syllabus: all 3 chapters

Expand any chapter to see its topics and sub-topics.

  1. Basics

    3 topics
    • CSS Syntax
    • Selectors
    • Box Model
  2. Layout

    3 topics
    • Flexbox
    • Grid
    • Positioning
  3. Advanced

    3 topics
    • Animations
    • Transitions
    • Responsive Design

Front-end Web Development CSS flashcards — 50 questions with answers

  1. What is the basic syntax structure of a CSS rule?

    A CSS rule consists of a selector followed by a declaration block: `selector { property: value; }`. Each declaration pairs a property with a value, separated by a colon and terminated by a semicolon.

  2. In CSS, what are the three ways to apply styles to an HTML document?

    Inline styles (the `style` attribute on an element), internal/embedded styles (a `<style>` block in the `<head>`), and external styles (a separate `.css` file linked with `<link rel="stylesheet">`).

  3. How do you write a comment in CSS?

    With `/* comment */`. CSS has no single-line comment syntax; all comments use the `/* ... */` delimiters.

  4. What does the universal selector `*` match, and how do you select an element by its type?

    The universal selector `*` matches every element. A type (element) selector such as `p` matches all elements of that tag name.

  5. How do you select elements by class versus by ID in CSS?

    A class selector uses a dot: `.classname`. An ID selector uses a hash: `#idname`. Classes can apply to many elements; an ID should be unique per page.

  6. What is the difference between the descendant combinator and the child combinator?

    The descendant combinator (a space, e.g. `div p`) selects all `p` elements nested anywhere inside a `div`. The child combinator (`div > p`) selects only `p` elements that are direct children of a `div`.

  7. What do the adjacent sibling (`+`) and general sibling (`~`) combinators select?

    `A + B` selects the first `B` element immediately preceded by an `A` sibling. `A ~ B` selects every `B` element that is a later sibling of an `A`, sharing the same parent.

  8. What is the difference between a pseudo-class and a pseudo-element?

    A pseudo-class (single colon, e.g. `:hover`, `:nth-child()`) targets an element in a particular state or position. A pseudo-element (double colon, e.g. `::before`, `::first-line`) styles a specific part of an element or inserts generated content.

  9. How is CSS specificity calculated, and which selector type wins?

    Specificity is a tuple of (inline, IDs, classes/attributes/pseudo-classes, type/pseudo-elements). Inline styles are highest, then ID selectors, then classes/attributes/pseudo-classes, then element/pseudo-element selectors. A higher count in a more significant category wins regardless of lower categories.

  10. What is the order of the cascade when determining which CSS declaration applies?

    The cascade resolves in order: importance (including `!important`), then specificity, then source order (the last matching rule of equal specificity wins).

  11. What are the four components of the CSS box model, from inside to outside?

    Content, padding, border, and margin. The content holds text/children, padding is space inside the border, the border surrounds the padding, and the margin is transparent space outside the border.

  12. With `box-sizing: content-box`, what is the total rendered width of an element?

    The width property applies to the content only, so total width is $$\text{total width} = \text{width} + 2 \times \text{padding} + 2 \times \text{border}$$ (margins add extra space outside but are not part of the box's rendered size).

  13. How does `box-sizing: border-box` change width calculation compared to the default?

    With `border-box`, the declared `width` includes content, padding, and border, so padding and border shrink the content area rather than adding to the total size. The element's rendered width equals the declared width.

  14. What is margin collapsing in the CSS box model?

    When two vertical margins of block-level elements meet, they collapse into a single margin equal to the larger of the two (not their sum). It applies to adjacent siblings and parent/child top/bottom margins, but not to horizontal margins, floats, or flex/grid items.

  15. What is the difference between the `padding` and `margin` shorthand value orders?

    Both follow the same clockwise order starting at top: `top right bottom left`. With two values it is `vertical horizontal`; with three values it is `top horizontal bottom`; with four values it is all sides explicitly.

  16. What property turns an element into a flex container, and what does it create?

    `display: flex` (or `inline-flex`) makes an element a flex container, establishing a flex formatting context for its direct children (the flex items), which are laid out along a main axis and a cross axis.

  17. What does `flex-direction` control, and what are its values?

    It sets the direction of the main axis. Values: `row` (default, left-to-right), `row-reverse`, `column` (top-to-bottom), and `column-reverse`.

  18. What is the difference between `justify-content` and `align-items` in flexbox?

    `justify-content` aligns flex items along the main axis (e.g. `flex-start`, `center`, `space-between`, `space-around`, `space-evenly`). `align-items` aligns items along the cross axis (e.g. `stretch`, `center`, `flex-start`, `flex-end`, `baseline`).

  19. What three properties does the `flex` shorthand combine, and in what order?

    `flex` is shorthand for `flex-grow`, `flex-shrink`, and `flex-basis`, in that order. For example, `flex: 1 1 0%` means grow 1, shrink 1, basis 0%.

  20. How does `flex-grow` distribute extra free space among flex items?

    Free space is divided in proportion to each item's `flex-grow` value. An item's extra space is $$\text{extra}_i = \text{free space} \times \frac{g_i}{\sum_j g_j}$$ where $g_i$ is that item's `flex-grow` factor.

Show the other 30 CSS flashcards
  1. What does `flex-wrap` do, and what is its default?

    `flex-wrap` controls whether flex items stay on one line or wrap onto multiple lines. The default is `nowrap` (single line); `wrap` allows wrapping top-to-bottom, and `wrap-reverse` wraps bottom-to-top.

  2. What property turns an element into a grid container, and what defines its columns and rows?

    `display: grid` (or `inline-grid`) creates a grid container. `grid-template-columns` and `grid-template-rows` define the sizes of the explicit columns and rows.

  3. What is the `fr` unit in CSS Grid?

    The `fr` unit represents a fraction of the remaining free space in the grid container. For example, `grid-template-columns: 1fr 2fr` splits available space so the second column is twice as wide as the first.

  4. What does `repeat(3, 1fr)` mean in a grid template, and what does `minmax()` do?

    `repeat(3, 1fr)` is shorthand for `1fr 1fr 1fr`, defining three equal columns. `minmax(min, max)` defines a track that is at least `min` and at most `max`, e.g. `minmax(100px, 1fr)`.

  5. What is the difference between `gap`, `row-gap`, and `column-gap` in grid and flex layouts?

    `gap` is shorthand setting the spacing between tracks/items; `row-gap` sets spacing between rows and `column-gap` between columns. `gap: 10px 20px` means a 10px row gap and 20px column gap.

  6. How do you place an item to span specific grid lines using `grid-column` and `grid-row`?

    Use `grid-column: start / end` and `grid-row: start / end` with line numbers, e.g. `grid-column: 1 / 3` spans from line 1 to line 3 (two columns). You can also use `span n`, e.g. `grid-column: span 2`.

  7. In CSS Grid, what is the difference between the explicit and implicit grid?

    The explicit grid is defined by `grid-template-rows/columns`. The implicit grid is auto-generated when items are placed outside the explicit grid; its track sizes come from `grid-auto-rows`/`grid-auto-columns` and flow direction from `grid-auto-flow`.

  8. What are the five values of the CSS `position` property?

    `static` (default, normal flow), `relative` (offset from its normal position), `absolute` (positioned relative to the nearest positioned ancestor), `fixed` (positioned relative to the viewport), and `sticky` (toggles between relative and fixed based on scroll).

  9. How does `position: absolute` determine its containing block?

    An absolutely positioned element is placed relative to its nearest ancestor whose `position` is not `static` (i.e. `relative`, `absolute`, `fixed`, or `sticky`). If no such ancestor exists, it is positioned relative to the initial containing block (viewport).

  10. How does `position: relative` differ from `position: absolute` regarding document flow?

    A `relative` element stays in the normal flow and reserves its original space; the `top/left/etc.` offsets shift it visually without affecting other elements. An `absolute` element is removed from normal flow, so it no longer reserves space and other elements ignore it.

  11. What is the difference between `position: fixed` and `position: sticky`?

    `fixed` removes the element from flow and pins it to the viewport so it stays put during scrolling. `sticky` keeps the element in flow and behaves like `relative` until a scroll threshold (set via `top`, etc.) is crossed, then it sticks like `fixed` within its containing block.

  12. What does the `z-index` property control, and what is required for it to take effect?

    `z-index` controls the stacking order of overlapping elements along the z-axis (higher values appear in front). It only applies to positioned elements (`position` not `static`) or flex/grid items, and operates within stacking contexts.

  13. What is a stacking context in CSS?

    A stacking context is a three-dimensional conceptual layer in which elements are stacked. It is created by the root element, positioned elements with a `z-index`, `opacity` less than 1, `transform`, `filter`, `will-change`, and others. `z-index` values only compete within the same stacking context.

  14. What is the difference between a CSS transition and a CSS animation?

    A transition interpolates a property between two states triggered by a change (e.g. `:hover`), requiring a trigger and only running once per change. An animation uses `@keyframes` to define multiple intermediate states, can run automatically, loop, and play without a trigger.

  15. What four properties does the `transition` shorthand combine?

    `transition-property`, `transition-duration`, `transition-timing-function`, and `transition-delay`. Example: `transition: opacity 0.3s ease-in 0.1s`.

  16. What are the common values of a transition/animation timing function?

    `linear`, `ease` (default), `ease-in`, `ease-out`, `ease-in-out`, `step-start`, `step-end`, plus custom `cubic-bezier(x1, y1, x2, y2)` and `steps(n, jump)` functions.

  17. What does the CSS `cubic-bezier()` timing function define?

    It defines a custom acceleration curve from two control points $$P_1 = (x_1, y_1), \quad P_2 = (x_2, y_2)$$ with the curve fixed between $(0,0)$ and $(1,1)$. The $x$ values must lie in $[0, 1]$, while $y$ values may exceed that range to create overshoot/bounce effects.

  18. How do you define a CSS animation sequence, and how is it referenced?

    Define the sequence with a `@keyframes name { ... }` block using `from`/`to` or percentage stops (e.g. `0% { } 50% { } 100% { }`). Reference it on an element with `animation-name: name` (or the `animation` shorthand).

  19. What properties control how many times a CSS animation repeats and its direction?

    `animation-iteration-count` sets the repeat count (a number or `infinite`). `animation-direction` sets play direction: `normal`, `reverse`, `alternate`, or `alternate-reverse`.

  20. What does `animation-fill-mode` control?

    It defines what styles apply before the animation starts and after it ends. Values: `none` (default), `forwards` (retain final keyframe), `backwards` (apply first keyframe during delay), and `both`.

  21. What is the difference between the `transform` properties `translate`, `scale`, and `rotate`?

    `translate(x, y)` moves an element, `scale(sx, sy)` resizes it (1 = original size), and `rotate(angle)` spins it around its transform origin, e.g. `rotate(45deg)`. They do not affect document flow and are GPU-accelerated.

  22. Why are `transform` and `opacity` preferred for animations over properties like `width` or `top`?

    `transform` and `opacity` can be composited by the GPU without triggering layout (reflow) or repaint of other elements, producing smoother, higher-performance animations. Animating `width`, `top`, or `margin` forces layout recalculation, which is costly.

  23. What is a media query, and what is its basic syntax?

    A media query applies CSS conditionally based on device characteristics. Syntax: `@media media-type and (feature: value) { rules }`, e.g. `@media screen and (max-width: 600px) { ... }`.

  24. What is the difference between `min-width` and `max-width` media queries in responsive design?

    `min-width` applies styles when the viewport is at least the given width (mobile-first, scaling up). `max-width` applies styles when the viewport is at most the given width (desktop-first, scaling down).

  25. What is the mobile-first approach to responsive design?

    Base styles are written for the smallest screens first, then progressively enhanced for larger viewports using `min-width` media queries. This keeps the default styles lightweight and ensures content works on constrained devices.

  26. What does the viewport meta tag do for responsive design?

    `<meta name="viewport" content="width=device-width, initial-scale=1">` sets the layout viewport to the device width and the initial zoom to 1, allowing media queries and responsive layouts to render correctly on mobile devices instead of a scaled-down desktop view.

  27. What is the difference between relative units `em` and `rem`?

    `em` is relative to the font-size of the element itself (or its parent for font-size), so it compounds through nesting. `rem` is relative only to the root element's (`<html>`) font-size, avoiding compounding.

  28. What do the viewport units `vw` and `vh` represent?

    `1vw` equals 1% of the viewport's width and `1vh` equals 1% of the viewport's height. So `width: 50vw` is half the viewport width. Related units include `vmin` and `vmax` (1% of the smaller/larger viewport dimension).

  29. How does the CSS `clamp()` function support responsive sizing?

    `clamp(min, preferred, max)` returns the preferred value but never below `min` or above `max`: $$\text{clamp} = \max(\text{min}, \min(\text{preferred}, \text{max}))$$ It is commonly used for fluid typography, e.g. `font-size: clamp(1rem, 2.5vw, 2rem)`.

  30. What is the difference between `display: none` and `visibility: hidden`?

    `display: none` removes the element entirely from the layout, so it occupies no space and is not rendered. `visibility: hidden` hides the element visually but it still occupies its space in the layout.

Front-end Web Development CSS FAQ

What is in the Front-end Web Development CSS syllabus?

Front-end Web Development CSS is split into 3 chapters: Basics, Layout and Advanced. Together they contain 9 topics.

How many chapters are in Front-end Web Development CSS?

3 chapters, containing 9 topics. The largest chapter is Basics, with 3 topics.

Are there flashcards for Front-end Web Development CSS?

Yes — a 50-card CSS deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.