๐ŸŒ Frontend Web Development ยท subject

Frontend Web Development CSS & Styling Syllabus

The CSS & Styling syllabus for Frontend Web Development in full: 6 chapters and 26 topics, every one listed below, plus 63 CSS & Styling flashcards with answers.

6Chapters
26Topics
63Flashcards

CSS & Styling syllabus: all 6 chapters

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

  1. CSS Fundamentals

    5 topics
    • Selectors & Specificity
    • The Cascade & Inheritance
    • Colors, Units & Values
    • Typography & Web Fonts
    • Backgrounds & Borders
  2. The Box Model & Layout

    4 topics
    • Box Model & box-sizing
    • Display & Positioning
    • Margins, Padding & Collapsing
    • Overflow & Z-index
  3. Flexbox & Grid

    4 topics
    • Flexbox Container & Items
    • CSS Grid Tracks & Areas
    • Gap, Alignment & Ordering
    • Choosing Flexbox vs Grid
  4. Responsive Design

    4 topics
    • Mobile-First Strategy
    • Media Queries & Breakpoints
    • Fluid Layouts & Relative Units
    • Container Queries
  5. Transitions, Animations & Effects

    4 topics
    • Transitions & Timing Functions
    • Keyframe Animations
    • Transforms (2D & 3D)
    • Filters, Gradients & Shadows
  6. Modern CSS Architecture

    5 topics
    • Custom Properties (CSS Variables)
    • Naming Conventions (BEM)
    • CSS Preprocessors (Sass)
    • Utility-First CSS (Tailwind)
    • CSS Modules & CSS-in-JS

Frontend Web Development CSS & Styling flashcards โ€” 63 questions with answers

  1. In CSS, what does a selector's specificity measure, and how is it commonly represented?

    Specificity is the weight a browser assigns to a selector to decide which rule wins when several target the same element. It is represented as a three-part value $(a, b, c)$: $a$ = number of ID selectors, $b$ = number of class/attribute/pseudo-class selectors, $c$ = number of type/element and pseudo-element selectors.

  2. Rank these selector categories from highest to lowest specificity: element selectors, inline styles, ID selectors, class selectors.

    Inline styles (highest) > ID selectors > class selectors (including attribute selectors and pseudo-classes) > element/type selectors (lowest). The universal selector $*$ adds no specificity.

  3. What is the specificity of the selector `#nav .item a:hover` expressed as $(a,b,c)$?

    $(1, 2, 1)$: one ID (`#nav`), two class/pseudo-class selectors (`.item` and `:hover`), and one type selector (`a`).

  4. How does the `!important` flag interact with normal specificity in the cascade?

    `!important` overrides normal declarations regardless of specificity. Among competing `!important` declarations, normal specificity and source order break the tie. It effectively creates a higher-priority layer above regular author declarations.

  5. What are the two selectors that carry zero specificity, and why are they useful?

    The universal selector `*` and the `:where()` pseudo-class both contribute zero specificity. They let you write low-priority defaults that are easy to override, unlike `:is()`, which takes the specificity of its most specific argument.

  6. Define 'the cascade' in CSS and list its ordering criteria.

    The cascade is the algorithm that resolves conflicting declarations for an element. It sorts by: (1) origin and importance (user agent, user, author; and whether `!important`), (2) specificity, then (3) source order โ€” later rules win among equal specificity.

  7. Which CSS properties are inherited by default, and which are not?

    Text-related properties (e.g. `color`, `font-family`, `font-size`, `line-height`, `visibility`, `list-style`) inherit by default. Box/layout properties (e.g. `margin`, `padding`, `border`, `width`, `background`) do not inherit.

  8. What do the CSS keywords `inherit`, `initial`, `unset`, and `revert` each do?

    `inherit` takes the parent's computed value; `initial` sets the property's spec-defined default; `unset` acts as `inherit` for inherited properties and `initial` otherwise; `revert` rolls back to the value from the previous cascade origin (e.g. the user-agent stylesheet).

  9. How does source order act as a tiebreaker in the cascade?

    When two declarations have the same origin, importance, and specificity, the one that appears later in the source (or in a later-loaded stylesheet) wins.

  10. List four common ways to specify a color in CSS and give an example of each.

    Named keyword (`red`), hexadecimal (`#ff0000` or shorthand `#f00`), RGB/RGBA (`rgb(255 0 0 / 0.5)`), and HSL/HSLA (`hsl(0 100% 50%)`). Modern CSS also adds `hwb()`, `lab()`, `lch()`, and `oklch()`.

  11. Distinguish absolute length units from relative length units in CSS, with examples.

    Absolute units have fixed physical size regardless of context: `px`, `pt`, `cm`, `in`. Relative units scale to something else: `em` (relative to element's font size), `rem` (root font size), `%`, `vw`/`vh` (viewport), `ch`, `ex`.

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

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

  13. If the root font size is $16\text{px}$ and an element is set to `font-size: 1.5rem`, what is its pixel size?

    $1.5 \times 16\text{px} = 24\text{px}$.

  14. What do the viewport units `vw`, `vh`, `vmin`, and `vmax` represent?

    $1\text{vw} = 1\%$ of viewport width; $1\text{vh} = 1\%$ of viewport height; `vmin` = $1\%$ of the smaller viewport dimension; `vmax` = $1\%$ of the larger dimension.

  15. What is the difference between a web-safe font and a web font (e.g. via `@font-face`)?

    A web-safe font is pre-installed on most devices (e.g. Arial, Georgia), so no download is needed. A web font is downloaded from a server via `@font-face` or a service like Google Fonts, giving custom typography at the cost of extra network requests.

  16. What does the `font-display` descriptor control, and what does `swap` do?

    `font-display` controls how text renders while a web font loads. `swap` shows fallback text immediately (avoiding invisible text/FOIT) and swaps to the web font once loaded, at the cost of a possible flash of unstyled text (FOUT).

  17. In the `font` shorthand, which sub-properties are mandatory?

    `font-size` and `font-family` are mandatory (and must appear last, in that order). Optional leading values are `font-style`, `font-variant`, `font-weight`, and a `line-height` given as `font-size/line-height`.

  18. What is the difference between `line-height` set as a unitless number versus a length like `px`?

    A unitless `line-height` (e.g. `1.5`) is inherited as a factor, so children multiply it by their own font size. A length or percentage computes a fixed value on the parent that children inherit directly, which can break spacing at different font sizes.

  19. In the `background` shorthand, what does the syntax `background: url(bg.png) no-repeat center / cover` mean?

    It sets `background-image` to `bg.png`, `background-repeat` to `no-repeat`, `background-position` to `center`, and (after the slash) `background-size` to `cover`. The slash separates position from size.

  20. What is the difference between `background-size: cover` and `background-size: contain`?

    `cover` scales the image to completely fill the container (cropping overflow while preserving aspect ratio). `contain` scales it so the entire image is visible inside the container (possibly leaving empty space), also preserving aspect ratio.

Show the other 43 CSS & Styling flashcards
  1. In the `border` shorthand, what three values are set and in what conceptual order?

    `border-width`, `border-style`, and `border-color` โ€” e.g. `border: 2px solid #333`. The `border-style` is required for the border to appear; without it the border is not rendered.

  2. How does `border-radius` accept values to make an elliptical corner?

    You provide horizontal and vertical radii separated by a slash, e.g. `border-radius: 20px / 40px`, giving each corner a horizontal radius of $20\text{px}$ and vertical radius of $40\text{px}$. A single value makes circular corners.

  3. Name the four layers of the CSS box model from innermost to outermost.

    Content, then padding, then border, then margin.

  4. Under the default `box-sizing: content-box`, how is the total rendered width of an element calculated?

    $$\text{total width} = \text{width} + 2\times\text{padding} + 2\times\text{border}$$ Margins add outside this but are not part of the box's rendered size. The `width` property applies only to the content area.

  5. How does `box-sizing: border-box` change width calculation, and why is it popular?

    With `border-box`, the `width` includes content, padding, and border, so padding/border shrink the content area instead of enlarging the box. This makes sizing predictable, which is why `*{ box-sizing: border-box; }` is a common reset.

  6. An element has `width: 200px`, `padding: 20px`, `border: 5px`, and `box-sizing: content-box`. What is its total rendered width?

    $200 + 2(20) + 2(5) = 200 + 40 + 10 = 250\text{px}$.

  7. Contrast the `display` values `block`, `inline`, and `inline-block`.

    `block` takes full available width and starts on a new line, honoring width/height. `inline` flows within text, ignores width/height and top/bottom margins. `inline-block` flows inline like text but respects width/height and all margins/padding.

  8. List the five values of the CSS `position` property and one defining trait of each.

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

  9. For an `position: absolute` element, which ancestor does it position against?

    The nearest ancestor with a `position` other than `static` (i.e. relative, absolute, fixed, or sticky). If none exists, it positions against the initial containing block (the viewport/`<html>`).

  10. How does `position: sticky` behave relative to scrolling?

    A sticky element scrolls normally until it reaches a specified offset (e.g. `top: 0`), then sticks in place like `fixed` while its containing block remains in view, releasing again when the container scrolls past.

  11. What is margin collapsing, and between which margins does it occur?

    Margin collapsing is when adjacent vertical margins combine into a single margin equal to the larger of the two, rather than summing. It occurs between vertical (top/bottom) margins of block-level boxes in normal flow โ€” including parent/first-child and empty blocks. Horizontal margins never collapse.

  12. When two collapsing margins are $30\text{px}$ and $20\text{px}$, what is the resulting margin?

    $\max(30, 20) = 30\text{px}$ โ€” the larger of the two, not their sum.

  13. How do negative margins affect the collapsing calculation?

    When both margins are negative, the more negative one is used. When one is positive and one negative, they are added together. For example, $40\text{px}$ and $-15\text{px}$ collapse to $40 + (-15) = 25\text{px}$.

  14. Name two ways to prevent a parent's margin from collapsing with its child's top margin.

    Add padding or a border to the top of the parent, set the parent's `overflow` to something other than `visible`, or establish a block formatting context (e.g. `display: flow-root`) on the parent.

  15. What are the four values of the `overflow` property and what does each do?

    `visible` (default; content spills outside the box), `hidden` (clips overflow, no scrollbars), `scroll` (always shows scrollbars), and `auto` (shows scrollbars only when needed).

  16. What is a stacking context, and name two ways to create one.

    A stacking context is a group of elements that stack together as a unit along the z-axis. It is created by, among others: the root element, a positioned element with a `z-index` other than `auto`, `opacity` less than 1, `transform`, `filter`, or `will-change`.

  17. On what kinds of elements does the `z-index` property take effect?

    `z-index` only affects elements that participate in a stacking context โ€” primarily positioned elements (`position` other than `static`) and flex/grid items. On a plain `static` element it has no effect.

  18. When you set `display: flex` on a container, what are the two axes called and how are they controlled?

    The main axis (controlled by `flex-direction`: `row`/`column`) and the cross axis (perpendicular to it). `justify-content` aligns items along the main axis; `align-items` aligns them along the cross axis.

  19. What do the three parts of the `flex` shorthand `flex: 1 1 0%` represent?

    `flex-grow` (here $1$: how much the item grows to fill free space), `flex-shrink` (here $1$: how much it shrinks when space is tight), and `flex-basis` (here $0\%$: the item's initial main-size before growing/shrinking).

  20. What is the difference between `justify-content` and `align-content` in a flex container?

    `justify-content` distributes space along the main axis. `align-content` distributes space between rows along the cross axis and only has an effect when there are multiple lines (i.e. `flex-wrap: wrap` and content wraps onto multiple lines).

  21. What does `align-self` do, and how does it relate to `align-items`?

    `align-items` sets the default cross-axis alignment for all flex items on the container. `align-self`, set on an individual item, overrides that default for just that item.

  22. In CSS Grid, distinguish a grid track, a grid line, and a grid cell.

    A track is a row or column (the space between two adjacent lines). A grid line is the dividing line between tracks (numbered starting at 1). A cell is the intersection of one row track and one column track โ€” the smallest unit.

  23. What does the `fr` unit do in `grid-template-columns`, e.g. `grid-template-columns: 1fr 2fr`?

    `fr` distributes remaining free space in fractions. With `1fr 2fr`, leftover space is split into $1 + 2 = 3$ parts: the first column gets $\frac{1}{3}$ and the second gets $\frac{2}{3}$.

  24. What does `repeat(auto-fill, minmax(200px, 1fr))` accomplish in a grid?

    It creates as many columns as fit, each at least $200\text{px}$ and at most $1\text{fr}$, automatically wrapping items into a responsive grid without media queries. `auto-fit` behaves similarly but collapses empty tracks so filled items stretch.

  25. How do you define and place items using named grid areas?

    Use `grid-template-areas` on the container to draw a text map of named regions (each string is a row), then assign each child `grid-area: <name>`. A `.` denotes an empty cell, and each area must form a rectangle.

  26. What does the `gap` property control, and how does its shorthand order work?

    `gap` sets spacing between flex/grid items (and multi-column layouts). `gap: 10px 20px` sets `row-gap: 10px` and `column-gap: 20px`; a single value applies to both. Unlike margins, gaps do not add space at the outer edges.

  27. What is the difference between `justify-items`/`justify-self` and `align-items`/`align-self` in CSS Grid?

    `justify-*` aligns grid items along the inline (row/horizontal) axis within their cells; `align-*` aligns them along the block (column/vertical) axis. The `-items` form sets the container default; the `-self` form overrides it per item.

  28. What does the `order` property do for flex and grid items, and what caveat applies?

    `order` (an integer, default $0$) changes the visual order in which items are laid out โ€” lower values come first. Caveat: it changes only visual order, not DOM/source order, so tab focus and screen-reader reading order still follow the source.

  29. When should you choose Flexbox versus CSS Grid?

    Use Flexbox for one-dimensional layouts (content arranged along a single row or column, sizing driven by content). Use Grid for two-dimensional layouts (rows and columns together, with an explicit layout structure). They can be nested and combined.

  30. What is the core idea of a mobile-first CSS strategy?

    Write the base styles for the smallest (mobile) screens first, then use `min-width` media queries to progressively add or enhance layout for larger screens. This yields simpler base CSS and better performance on constrained devices.

  31. Contrast `min-width` and `max-width` media queries in the context of mobile-first vs desktop-first design.

    `min-width` queries apply from a breakpoint upward (used in mobile-first, enhancing as screens grow). `max-width` queries apply up to a breakpoint (used in desktop-first, adapting downward). Mobile-first favors `min-width`.

  32. Write a media query that applies styles only when the viewport is at least $768\text{px}$ wide.

    `@media (min-width: 768px) { /* styles */ }` โ€” the rules inside apply when the viewport width is $\geq 768\text{px}$.

  33. How do you combine conditions in a media query using `and`, and target orientation?

    Chain features with `and`, e.g. `@media (min-width: 600px) and (max-width: 900px) and (orientation: landscape)`. This applies only when width is between $600\text{px}$ and $900\text{px}$ and the device is in landscape.

  34. What is the recommended viewport `<meta>` tag for responsive design, and why is it needed?

    `<meta name="viewport" content="width=device-width, initial-scale=1">`. It tells the browser to match the layout viewport to the device width and set zoom to $1$, so responsive CSS and media queries behave correctly on mobile.

  35. What makes a layout 'fluid' rather than 'fixed', and which units support it?

    A fluid layout sizes elements in relative units so they scale with the viewport or container, rather than fixed pixels. Supporting units include `%`, `vw`/`vh`, `fr`, `em`/`rem`, and `ch`, often combined with `min()`, `max()`, and `clamp()`.

  36. What does the `clamp(MIN, PREFERRED, MAX)` function do, and give a fluid-typography example.

    `clamp()` returns the PREFERRED value but never below MIN or above MAX. For fluid type: `font-size: clamp(1rem, 2.5vw, 2rem)` scales with the viewport yet stays between $1\text{rem}$ and $2\text{rem}$.

  37. How does a container query differ from a media query?

    A media query responds to the viewport (or device) dimensions. A container query responds to the size of a specified ancestor container, letting a component adapt based on its own available space regardless of viewport โ€” ideal for reusable components.

  38. How do you set up an element to be queried by container queries, and how do you write the query?

    On the parent, declare `container-type: inline-size` (optionally `container-name: card`). Then query it with `@container card (min-width: 400px) { ... }`, styling descendants based on the container's width.

  39. What is the `cqw` unit and what does it reference?

    `cqw` is a container query length unit where $1\text{cqw} = 1\%$ of the query container's width. Related units include `cqh` (height), `cqi` (inline size), `cqb` (block size), `cqmin`, and `cqmax`.

  40. What four sub-properties does the `transition` shorthand combine, and in what order?

    `transition-property`, `transition-duration`, `transition-timing-function`, and `transition-delay` โ€” e.g. `transition: opacity 0.3s ease-in 0.1s`. The first time value is duration; the second is delay.

  41. Name the common built-in CSS transition timing-function keywords and what `ease` does.

    `linear`, `ease` (default), `ease-in`, `ease-out`, `ease-in-out`, plus `steps()` and custom `cubic-bezier()`. `ease` starts slowly, speeds up in the middle, and slows down at the end.

  42. What is the mathematical form of a `cubic-bezier()` timing function's control points?

    `cubic-bezier(x1, y1, x2, y2)` defines two control points $P_1 = (x_1, y_1)$ and $P_2 = (x_2, y_2)$ of a curve from $(0,0)$ to $(1,1)$. The $x$-values must satisfy $0 \leq x_1, x_2 \leq 1$, while $y$-values may exceed that range to create overshoot.

  43. Why do transitions animate smoothly on `transform` and `opacity` but not on `display: none`?

    `transform` and `opacity` are animatable, continuously interpolable properties (and GPU-accelerated). `display` is discrete/non-animatable โ€” historically it snaps instantly โ€” so an element toggled to `display: none` disappears without a transition unless newer discrete-animation techniques (e.g. `@starting-style`, `transition-behavior: allow-discrete`) are used.

Frontend Web Development CSS & Styling FAQ

What is in the Frontend Web Development CSS & Styling syllabus?

Frontend Web Development CSS & Styling is split into 6 chapters: CSS Fundamentals, The Box Model & Layout, Flexbox & Grid, Responsive Design, Transitions, Animations & Effects and Modern CSS Architecture. Together they contain 26 topics.

How many chapters are in Frontend Web Development CSS & Styling?

6 chapters, containing 26 topics. The largest chapter is CSS Fundamentals, with 5 topics.

Are there flashcards for Frontend Web Development CSS & Styling?

Yes โ€” a 63-card CSS & Styling 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.