CSS Code Challenges
Master CSS from beginner syntax to advanced 3D transforms, container queries, and subgrid with interactive, hands-on coding problems.
Text Color
Set the text color of the heading (.title) to red.
Background Color
Set the background color of the .box element to #3b82f6 (blue).
Font Size
Increase the font size of paragraphs (.content) to 20px.
Font Weight Bold
Make the .emphasis text bold.
Text Alignment
Center align the heading inside .banner.
Padding All Sides
Apply 24px of internal padding to all four sides of .card.
Margin Auto Centering
Horizontally center the fixed-width .container by setting horizontal margin to auto.
Border Radius (Rounded Corners)
Round the corners of the .badge element with an 8px border-radius.
Solid Border
Add a 2px solid border with color #000 to .outline-box.
Box-Sizing: Border-Box
Ensure padding and border are included in total element width and height using box-sizing.
Display: Flex
Turn .flex-row into a flex container using the display property.
Flexbox Gap
Set a 16px gap between items in the .flex-list container.
Flex Justify Content: Center
Horizontally center flex items along the main axis using justify-content.
Flex Align Items: Center
Vertically center flex items along the cross axis using align-items.
Flex Justify Space-Between
Distribute items evenly so the first is at the start and the last is at the end.
Display: None (Hide Element)
Hide the element with class .hidden from the rendered page.
Opacity
Make .semi-transparent 50% transparent using the opacity property.
Line Height
Set a comfortable line-height of 1.6 on the article paragraph.
Text Decoration: None
Remove the default underline from links styled with class .clean-link.
Text Transform: Uppercase
Transform the text in .label to uppercase capital letters.
Circle with Border-Radius
Turn a 60px by 60px .avatar into a perfect circle.
Letter Spacing
Add 2px of letter-spacing to the .tracking-wide element.
Cursor: Pointer
Make the mouse cursor turn into a pointer hand when hovering over .clickable.
Hover Pseudo-Class
Change the background color of .btn to #2563eb when hovered (:hover).
Position Relative
Set position to relative on .parent so child absolute elements can anchor to it.
Position Absolute (Top Right Pin)
Position .pin absolutely at top: 0 and right: 0 inside its container.
Overflow Hidden
Clip any content spilling outside of .clipped-container using overflow.
Font Family Fallback Stack
Set font-family on .text to Inter with fallback to sans-serif.
Display: Inline-Block
Allow width and height to take effect on the inline .tag element using display: inline-block.
CSS Variable Definition
Declare a custom property named --brand-color with value #6366f1 on :root.
CSS Variable Usage var()
Apply the custom variable var(--brand-color) as the background color of .hero.
Basic Box Shadow
Add a subtle drop shadow to .card: 0px 4px 6px with color rgba(0,0,0,0.1).
Descendant Selector
Style all p tags inside .card with color #475569.
Direct Child Selector
Target only direct child li elements of .menu using the child combinator (>).
ID Selector
Target the element with id #unique-header and set its color to #0f172a.
Flex Wrap Rows
Allow flex items in .badge-container to wrap onto multiple lines when space runs out.
Flex Grow Proportion
Make .grow-item expand to fill all remaining available space inside the flex container.
CSS Grid 3-Column Layout
Create a 3-column equal grid using grid-template-columns with 1fr fraction units.
Grid Gap (Rows and Columns)
Set a 20px gap between both rows and columns in .grid-box.
Grid Column Span
Make the .featured card span across 2 columns in the grid.
Responsive Grid Auto-Fit
Create an auto-fitting responsive grid where columns are at least 200px wide up to 1fr.
Sticky Header
Make .site-header stick to the top of the viewport when scrolling using position: sticky and top: 0.
Z-Index & Stacking Context
Ensure .modal appears on top of overlapping relative elements with a z-index of 50.
Transition Duration & Timing
Add a 0.3s ease transition for all properties on .animated-card.
2D Transform: Scale
Scale .btn by 1.05 when hovered (:hover).
2D Transform: TranslateY
Lift .card upwards by 4px on hover using transform: translateY(-4px).
Media Query for Mobile Breakpoint
Add a media query for screens with max-width: 640px to set .stack flex-direction to column.
Clamp() for Fluid Typography
Use clamp(1rem, 2.5vw, 2rem) for fluid responsive font-size on .fluid-title.
Pseudo-Element ::before
Add a bullet symbol (content: "โข ") before items in .custom-list li using ::before.
First-Child Selector
Remove top border on only the :first-child element of .list-item.
Nth-Child Even Stripes
Give alternating even rows in tr:nth-child(even) a background of #f8fafc.
Linear Gradient Background
Create a background linear-gradient from to right from #4f46e5 to #06b6d4 on .gradient-bg.
Aspect Ratio 16 / 9
Enforce a widescreen 16/9 aspect ratio on the .video-frame element using aspect-ratio.
Object Fit: Cover
Prevent image distortion inside fixed-size .cover-img using object-fit: cover.
Text Truncate with Ellipsis
Truncate overflowing text on a single line in .truncate with an ellipsis (...).
Pointer Events None
Allow clicks to pass through .overlay to underlying elements using pointer-events: none.
User Select None
Prevent text selection when double-clicking on .unselectable button.
Accent Color for Inputs
Set the custom accent-color of the checkbox .themed-check to #10b981.
Backdrop Filter Blur
Create a frosted glass blur effect on .glass-panel using backdrop-filter: blur(10px).
Scroll Behavior Smooth
Enable smooth page scrolling across anchor links on the html root element.
Rotate 45deg
Rotate the diamond .diamond by 45 degrees using transform: rotate(45deg).
CSS Calc Function
Calculate .sidebar-offset width as calc(100% - 250px).
Media Query Prefers-Color-Scheme Dark
Write a media query for (prefers-color-scheme: dark) that sets body background to #0f172a.
Multi-Column Layout
Split the .newspaper article into 3 columns using column-count: 3 and column-gap: 24px.
Min-Height Viewport 100vh
Ensure .hero-landing takes at least the full height of the viewport with min-height: 100vh.
Align Self in Flexbox
Override the container align-items and align .special-item to flex-end.
Order Property in Flexbox
Reorder .first-element to appear visually last using order: 99.
Text Shadow Effect
Add a glowing text shadow to .glowing-headline: 0 0 10px #38bdf8.
Clip-Path Polygon (Triangle)
Clip the square .triangle element into a polygon triangle: 50% 0%, 0% 100%, 100% 100%.
CSS Filter Invert
Invert the colors of .invert-target completely using filter: invert(1).
Scroll Snap Mandatory
Enable horizontal mandatory scroll snapping on .carousel container.
Scroll Snap Align Start
Align each .slide item to the start edge of the snapping container.
Custom Checkbox :checked Selector
Change the color of label adjacent to checked input: input:checked + label to #16a34a.
Logical Properties (Margin-Inline)
Set internationalization-friendly horizontal margins using margin-inline: auto on .i18n-box.
CSS Specificity Override (!important)
Force the color of .override to #dc2626 using the !important flag.
Keyframe Spin Animation
Define an @keyframes spin that rotates from 0deg to 360deg, and apply it to .loader for 1s linear infinite.
Pulse Opacity Animation
Create a pulse animation that animates opacity between 1 and 0.4 on .pulsing-dot.
3D Perspective & Preserve-3D
Enable 3D space on .card-3d-wrap with perspective: 1000px, and set transform-style: preserve-3d on .card-inner.
3D Card Flip (RotateY)
Flip .card-inner horizontally when parent .card-flip is hovered: transform: rotateY(180deg).
Modern Relational Pseudo-Class :has()
Select .card that contains an <img /> element using the modern parent selector .card:has(img) and add padding: 0.
:is() Selector Matching
Compact h1, h2, and h3 inside article using article :is(h1, h2, h3) with color: #0284c7.
:where() Zero Specificity Selector
Use :where(button, .btn) with zero specificity to set border: none.
Container Query Definition (Size)
Define container-type: inline-size on .card-parent to register it as a container query context.
@container Query Rule
Apply @container (min-width: 400px) so .card switches to display: flex.
CSS Subgrid
Make the nested .subgrid-item inherit parent columns using grid-template-columns: subgrid.
Cascade Layers (@layer)
Declare an author layer named components using @layer components { .btn { padding: 12px; } }.
Native CSS Nesting
Nest the hover pseudo-class inside .nav-item using the native & nesting syntax (&:hover { color: #2563eb; }).
Modern Color Space: OKLCH
Set background color using perceptual modern oklch color: oklch(0.65 0.25 150) on .oklch-box.
Color-Mix() Modern Function
Mix 80% blue with 20% white using color-mix(in srgb, blue 80%, white) on .mixed-bg.
Animation Fill Mode Forwards
Ensure .slide-in retains its final keyframe values after completion using animation-fill-mode: forwards.
Cubic Bezier Timing Curve
Apply an energetic bouncy cubic-bezier(0.68, -0.55, 0.27, 1.55) to transition on .bounce-btn.
Custom CSS Counter
Initialize a counter called section-counter on ol, and increment it with counter-increment on li.
Conic Gradient Wheel
Create a circular color wheel on .color-wheel using conic-gradient(red, yellow, lime, aqua, blue, magenta, red).
Mix Blend Mode Difference
Invert text automatically against light and dark backgrounds using mix-blend-mode: difference on .invert-text.
CSS Mask Image (Linear Gradient)
Fade out bottom text using mask-image: linear-gradient(to bottom, black 50%, transparent 100%) on .fade-mask.
CSS Motion Path (Offset-Path)
Constrain the moving element .orbit-dot along a path using offset-path: path("M 0 0 L 100 100").
Prefers Reduced Motion Query
Respect user motion sensitivity by disabling transitions and animations inside @media (prefers-reduced-motion: reduce).
CSS Scoping (@scope)
Scope styles to .card-component excluding .card-body using @scope (.card-component) to (.card-body).
CSS Field-Sizing: Content (Auto-Growing Textarea)
Allow .auto-textarea to grow dynamically with user input text using modern field-sizing: content.
Master CSS Architecture: 3D Flip Card Component
Combine flexbox centering, 3D perspective (1000px), transform-style: preserve-3d, and backface-visibility: hidden to build a complete interactive card component.