i need css question from basic to advance
- User
i need css question from basic to advance
- 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 AdvancedEach 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 1 What does CSS stand for, and why is it used? 2 Which HTML tag is used to link an external stylesheet? 3 Write the correct syntax to give every <p>element red text.4 In the rule h1 { color: blue; }, name each part (selector, property, value).5 What are the 3 ways to add CSS to a webpage? 6 Explain the difference between a class selector ( .box) and an ID selector (#box).7 What character begins a CSS comment? 8 Which unit is relative to the root element’s font-size? 9 How do you make text bold with CSS? 10 What does the * { box-sizing: border-box; }rule do?11 How can you import one stylesheet into another? 12 Name two differences between marginandpadding.13 How would you select all <a>tags inside a<nav>?14 What property controls the size of text? 15 Which keyword resets a property to the browser’s default? - Cascading Style Sheets – used to separate content (HTML) from presentation (layout, colors, fonts).
<link rel="stylesheet" href="styles.css">inside<head>.
p { color: red; }h1= selector,color= property,blue= value.- External (
<link>), Internal (<style>block), Inline (style=""). - Classes can be reused multiple times; IDs must be unique per page and have higher specificity.
/* comment */starts with/*.rem.font-weight: bold;or numericfont-weight: 700;.- Makes padding & border count inside the declared width/height.
@import url("other.css");at the top of a file.- Margin is outside the border and can collapse; padding is inside and adds to clickable area.
nav a { ... }.font-size.initialorunset(depending on need).
🌿 Intermediate (Dig-in)
# Question 16 Explain the difference between absolute and relative positioning. 17 What is the CSS cascade and how do specificity and source order influence it? 18 When do margin-collapsing rules apply? 19 What’s the default display value for a <div>and for a<span>?20 How do you create a flex container? 21 Describe three main axis properties in Flexbox. 22 What is the purpose of z-indexand when is it applied?23 Give two use-cases for pseudo-elements like ::beforeor::after.24 Differentiate between emandrem.25 How do media queries work, and what problem do they solve? 26 What is “stacking context”? 27 Write a selector that targets every even row in a table. 28 Explain the difference between opacity: 0;andvisibility: hidden;.29 What are CSS custom properties (a.k.a variables), and how do you declare one? 30 Why might you use will-changeand what are its trade-offs?- Relative is positioned relative to itself (leaving space), absolute is taken out of normal flow and positioned relative to the nearest positioned ancestor.
- The cascade decides which style “wins.” Specificity (inline > ID > class > element) and later rules override earlier ones if equally specific.
- Collapses for vertical margins between two block elements that are not separated by padding/border.
<div>=block;<span>=inline.display: flex;on a parent.flex-direction,justify-content,align-items.- Controls stacking order of positioned elements within a stacking context.
- Decorative icons, adding quotes/ornaments without extra markup, etc.
emis relative to the element’s own font-size;remto the root (html) font-size.- Conditional blocks like
@media (max-width: 600px) { ... }adapt styles to device characteristics. - A 3-D layer in which
z-indexis respected; created by certain properties (positioned withz-index,opacity < 1, etc.). tr:nth-child(even) { ... }.- Opacity removes element from pointer events and fully transparent; visibility hides but still occupies space & accepts events (when
visibility: hidden). :root { --brand: #f06; } .btn { color: var(--brand); }.- Hints browser to prepare for animation → smoother; overuse can hurt memory/perf.
🌳 Advanced (Boss-level)
# Question 31 Explain how subgrid differs from normal CSS Grid behavior. 32 What is content-visibility and how can it improve performance? 33 How do contain and contain-intrinsic-size work together? 34 Why can’t transformandtop/leftanimate together seamlessly?35 Detail how the BEM methodology structures class names. 36 Describe 4 ways to create a new stacking context. 37 Compare CSS Modules, Shadow DOM, and Scoped CSS approaches. 38 What are the pros/cons of using @extends(Sass) vs. mixins?39 How does aspect-ratiointeract with an element’s width/height rules?40 What is a logical property? Give two examples and why they’re useful for RTL layouts. 41 Explain layered CSS using @layerand why it helps avoid specificity wars.42 Describe how CSS Houdini allows extending the rendering pipeline (mention at least paint worklet).43 Give an example of using accent-colorand explain browser support.44 How does prefers-reduced-motionmedia query influence UX decisions?45 Where can FOUC come from and how can you mitigate it? subgridallows child grid items to inherit and align to the track lines of their parent grid container.content-visibility: auto;lets the browser skip rendering content outside the viewport until needed, boosting performance.containlimits an element’s scope for layout/paint;contain-intrinsic-sizegives the engine a placeholder size before actual rendering.transformis GPU accelerated and doesn’t affect layout;top/lefttriggers layout. Mixing causes jank due to different compositor paths.- BEM: Block (
.card), Element (.card__title), Modifier (.card--primary). - Positioned with
z-index,opacity < 1,transform/filter/will-change,isolation: isolate,mix-blend-mode, etc. - 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. @extendsshares selector grouping (can bloat selector list); Mixins copy declarations (can bloat output). Use based on DRY vs. size tradeoff.- If only width is set, height auto-adjusts to keep the ratio; vice versa. Both set? ratio is ignored.
- Logical properties adapt to writing mode:
margin-inline-start,padding-block-end. RTL gets automatic flipping. @layer base, components, utilities;then assign rules to layers so later ones win without specificity bumps.- 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!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.