Skip to content
The Chat Archive
o3-2025-04-16· OpenAI LMArena Human Preference 140K

i need css question from basic to advance

  1. User

    i need css question from basic to advance

  2. Assistant

    Below is a curated ladder of CSS interview/quiz questions that gradually move from “just-getting-started” to “CSS wizard.”
    • 15 Basic
    • 15 Intermediate
    • 15 Advanced

    Each question’s answer is tucked away in a collapsible <details> block—click to reveal when you’re ready to check yourself.


    🌱 Basic (Warm-up)

    #Question
    1What does CSS stand for, and why is it used?
    2Which HTML tag is used to link an external stylesheet?
    3Write the correct syntax to give every <p> element red text.
    4In the rule h1 { color: blue; }, name each part (selector, property, value).
    5What are the 3 ways to add CSS to a webpage?
    6Explain the difference between a class selector (.box) and an ID selector (#box).
    7What character begins a CSS comment?
    8Which unit is relative to the root element’s font-size?
    9How do you make text bold with CSS?
    10What does the * { box-sizing: border-box; } rule do?
    11How can you import one stylesheet into another?
    12Name two differences between margin and padding.
    13How would you select all <a> tags inside a <nav>?
    14What property controls the size of text?
    15Which keyword resets a property to the browser’s default?
    1. Cascading Style Sheets – used to separate content (HTML) from presentation (layout, colors, fonts).
    2. <link rel="stylesheet" href="styles.css"> inside <head>.
    p { color: red; }
    
    1. h1 = selector, color = property, blue = value.
    2. External (<link>), Internal (<style> block), Inline (style="").
    3. Classes can be reused multiple times; IDs must be unique per page and have higher specificity.
    4. /* comment */ starts with /*.
    5. rem.
    6. font-weight: bold; or numeric font-weight: 700;.
    7. Makes padding & border count inside the declared width/height.
    8. @import url("other.css"); at the top of a file.
    9. Margin is outside the border and can collapse; padding is inside and adds to clickable area.
    10. nav a { ... }.
    11. font-size.
    12. initial or unset (depending on need).

    🌿 Intermediate (Dig-in)

    #Question
    16Explain the difference between absolute and relative positioning.
    17What is the CSS cascade and how do specificity and source order influence it?
    18When do margin-collapsing rules apply?
    19What’s the default display value for a <div> and for a <span>?
    20How do you create a flex container?
    21Describe three main axis properties in Flexbox.
    22What is the purpose of z-index and when is it applied?
    23Give two use-cases for pseudo-elements like ::before or ::after.
    24Differentiate between em and rem.
    25How do media queries work, and what problem do they solve?
    26What is “stacking context”?
    27Write a selector that targets every even row in a table.
    28Explain the difference between opacity: 0; and visibility: hidden;.
    29What are CSS custom properties (a.k.a variables), and how do you declare one?
    30Why might you use will-change and what are its trade-offs?
    1. Relative is positioned relative to itself (leaving space), absolute is taken out of normal flow and positioned relative to the nearest positioned ancestor.
    2. The cascade decides which style “wins.” Specificity (inline > ID > class > element) and later rules override earlier ones if equally specific.
    3. Collapses for vertical margins between two block elements that are not separated by padding/border.
    4. <div> = block; <span> = inline.
    5. display: flex; on a parent.
    6. flex-direction, justify-content, align-items.
    7. Controls stacking order of positioned elements within a stacking context.
    8. Decorative icons, adding quotes/ornaments without extra markup, etc.
    9. em is relative to the element’s own font-size; rem to the root (html) font-size.
    10. Conditional blocks like @media (max-width: 600px) { ... } adapt styles to device characteristics.
    11. A 3-D layer in which z-index is respected; created by certain properties (positioned with z-index, opacity < 1, etc.).
    12. tr:nth-child(even) { ... }.
    13. Opacity removes element from pointer events and fully transparent; visibility hides but still occupies space & accepts events (when visibility: hidden).
    14. :root { --brand: #f06; } .btn { color: var(--brand); }.
    15. Hints browser to prepare for animation → smoother; overuse can hurt memory/perf.

    🌳 Advanced (Boss-level)

    #Question
    31Explain how subgrid differs from normal CSS Grid behavior.
    32What is content-visibility and how can it improve performance?
    33How do contain and contain-intrinsic-size work together?
    34Why can’t transform and top/left animate together seamlessly?
    35Detail how the BEM methodology structures class names.
    36Describe 4 ways to create a new stacking context.
    37Compare CSS Modules, Shadow DOM, and Scoped CSS approaches.
    38What are the pros/cons of using @extends (Sass) vs. mixins?
    39How does aspect-ratio interact with an element’s width/height rules?
    40What is a logical property? Give two examples and why they’re useful for RTL layouts.
    41Explain layered CSS using @layer and why it helps avoid specificity wars.
    42Describe how CSS Houdini allows extending the rendering pipeline (mention at least paint worklet).
    43Give an example of using accent-color and explain browser support.
    44How does prefers-reduced-motion media query influence UX decisions?
    45Where can FOUC come from and how can you mitigate it?
    1. subgrid allows child grid items to inherit and align to the track lines of their parent grid container.
    2. content-visibility: auto; lets the browser skip rendering content outside the viewport until needed, boosting performance.
    3. contain limits an element’s scope for layout/paint; contain-intrinsic-size gives the engine a placeholder size before actual rendering.
    4. transform is GPU accelerated and doesn’t affect layout; top/left triggers layout. Mixing causes jank due to different compositor paths.
    5. BEM: Block (.card), Element (.card__title), Modifier (.card--primary).
    6. Positioned with z-index, opacity < 1, transform/filter/will-change, isolation: isolate, mix-blend-mode, etc.
    7. CSS Modules = hash-scoped classes at build time; Shadow DOM = runtime scoped styles; Scoped CSS (e.g., Vue <style scoped>) combines attributes at compile time.
    8. @extends shares selector grouping (can bloat selector list); Mixins copy declarations (can bloat output). Use based on DRY vs. size tradeoff.
    9. If only width is set, height auto-adjusts to keep the ratio; vice versa. Both set? ratio is ignored.
    10. Logical properties adapt to writing mode: margin-inline-start, padding-block-end. RTL gets automatic flipping.
    11. @layer base, components, utilities; then assign rules to layers so later ones win without specificity bumps.
    12. Houdini exposes APIs (CSS.registerProperty, Paint Worklets) letting devs draw directly to CSS.
    input[type="checkbox"] { accent-color: rebeccapurple; }
    

    Supported in modern Chromium, Firefox, Safari 15+.
    44. Detects users who prefer minimal motion; use to disable parallax/auto-scrolling animations.
    45. Flash Of Unstyled Content arises when stylesheets load after HTML; mitigate with preload, inline critical CSS, or SSR styling.


    Need more?

    • Want code challenges, live tasks, or in-depth explanations?
    • Prefer the questions without answers for a test sheet?

    Just let me know and I’ll tweak the list!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.