Category

CSS Tutorials

Deep-dive CSS tutorials covering flexbox, grid, animations, transforms, custom properties and modern layout techniques. From beginner to advanced — with code you can copy and use today.

76
Total Tutorials
18
New this month
Showing 12 of 76 · page 1 of 7
CSS Dark Mode 2026: prefers-color-scheme, light-dark, OKLCH
CSS
19 min
Jun 10, 2026
CSS Dark Mode 2026: prefers-color-scheme, light-dark, OKLCH
The complete 2026 CSS dark mode guide — prefers-color-scheme media query, the new light-dark() function with the color-scheme gotcha, OKLCH tokens with color-mix() for perceptual lightness scaling, Material 3 surface elevation, View Transitions API for the toggle animation, the SSR/SSG FOUC fix matrix (Next.js cookie pattern), Windows High Contrast Mode survival with forced-colors, meta theme-color for mobile chrome, Tailwind v4 @custom-variant dark, and cross-tab sync.
W
W3Tweaks Team
CSS aspect-ratio Property: Complete Guide With Live Visualiser
CSS
19 min
Jun 9, 2026
CSS aspect-ratio Property: Complete Guide With Live Visualiser
CSS aspect-ratio is one line where the old padding-bottom hack needed five. It reserves space proportionally, eliminates layout shift, and works natively in every browser since 2021. This guide covers every value, the auto fallback for images, the gotchas with flexbox and content overflow, CSS custom-property patterns, Tailwind/Bootstrap equivalents, the @media (aspect-ratio) vs property disambiguation, view-transition interpolation, social-card cropping with object-position, and a complete common-ratios reference.
W
W3Tweaks Team
CSS mask: Fade, Reveal & Shape Elements (Complete 2026 Guide)
CSS
21 min
Jun 8, 2026
CSS mask: Fade, Reveal & Shape Elements (Complete 2026 Guide)
CSS mask uses another image or gradient as a stencil for element visibility. Unlike clip-path's hard edges, mask creates soft fades, partial transparency, and graduated reveals. This 2026 guide covers the alpha vs luminance reality (not just black=visible), gradient masks, SVG icon recoloring with currentColor, scroll container edge fades, spotlight hover, wipe reveals, scroll-driven animation-timeline reveals, mask-composite + mask-border, and the -webkit-mask-composite naming mismatch that silently breaks Safari.
W
W3Tweaks Team
CSS mix-blend-mode: Blend Text, Images & Colors Like Photoshop (2026)
CSS
21 min
Jun 7, 2026
CSS mix-blend-mode: Blend Text, Images & Colors Like Photoshop (2026)
mix-blend-mode lets an element's pixels react to whatever is behind them — the same algorithms Photoshop uses. Remove white backgrounds from logos. Make text always readable (with the WCAG caveat nobody mentions). Build duotone photos in pure CSS or with Spotify-style SVG feColorMatrix. Plus the interaction matrix when mix-blend-mode silently stops working with opacity/filter/transform, plus-lighter/plus-darker (CSS Blending Level 2), animation behavior, glitch/chromatic-aberration patterns, and forced-colors fallbacks.
W
W3Tweaks Team
CSS filter & backdrop-filter: The Complete 2026 Visual Guide
CSS
21 min
Jun 6, 2026
CSS filter & backdrop-filter: The Complete 2026 Visual Guide
CSS filter applies effects to an element — blur, grayscale, brightness, contrast, drop-shadow. CSS backdrop-filter applies those same effects to whatever is behind the element. This 2026 complete guide covers both properties, the filter-order gotcha, drop-shadow vs box-shadow, glassmorphism patterns (including Apple's Liquid Glass + dialog::backdrop modals), filter: url() for SVG-referenced effects like duotone and gooey blobs, prefers-reduced-transparency, @supports fallbacks, forced-colors mode, the iOS Safari fixed-position bug, and performance tiers.
W
W3Tweaks Team
CSS clip-path: Create Any Shape — The Complete 2026 Guide
CSS
21 min
Jun 5, 2026
CSS clip-path: Create Any Shape — The Complete 2026 Guide
clip-path lets you cut any element into any shape — circles, hexagons, arrows, diagonals, chevrons — with pure CSS. No SVG files, no image masks, no extra HTML. This 2026 complete guide covers every value, animation patterns, the new shape()/rect()/xywh() functions, scroll-driven reveals with animation-timeline: view(), clip-path: url() for arbitrary SVG paths, the Clippy generator, hover/click area gotchas, @keyframes loops, and the wrong-tool bugs nobody demonstrates.
W
W3Tweaks Team
CSS scroll-snap: Build a CSS Carousel Without JavaScript (2026 Guide)
CSS
25 min
Jun 4, 2026
CSS scroll-snap: Build a CSS Carousel Without JavaScript (2026 Guide)
Build a CSS carousel without JavaScript in 5 lines of CSS. This complete 2026 guide covers every scroll-snap property, mandatory vs proximity, the new scrollsnapchange event, scroll-padding for sticky headers, the 2026 CSS Carousel API (::scroll-marker and ::scroll-button), scroll-driven animations paired with snap, the 100dvh fix for mobile, drag-to-scroll for desktop, keyboard accessibility, and 'scroll snap not working' troubleshooting.
W
W3Tweaks Team
CSS @font-face: The Complete Guide to Loading Custom Fonts Right
CSS
29 min
Jun 3, 2026
CSS @font-face: The Complete Guide to Loading Custom Fonts Right
Most @font-face tutorials cover the basics and say 'add font-display: swap'. That's not wrong, but it's about 20% of what you need to know. This guide covers all 5 font-display values, variable font axes, font-synthesis: none, the Font Loading API, font-variant-numeric, modern system font stacks, the adjusted fallback pattern that eliminates layout shift, unicode-range, FOIT/FOUT/FOFT, preload's LCP trade-off, and whether you should still use local() in 2026.
W
W3Tweaks Team
CSS Selectors You're Not Using (But Should Be)
CSS
24 min
Jun 2, 2026
CSS Selectors You're Not Using (But Should Be)
You know div, .class, and #id. But CSS has dozens of selectors that replace JavaScript event listeners, eliminate helper classes, and handle UI state in pure CSS. This guide covers the underused ones actually worth learning — :has(), :focus-within, :user-valid, :nth-child(of selector), :where()'s zero-specificity trick, the :checked + ~ state machine, :target for routable UI, @scope, :defined, :dir(), and more.
W
W3Tweaks Team
CSS Specificity Explained: The Complete Cascade Guide
CSS
24 min
Jun 1, 2026
CSS Specificity Explained: The Complete Cascade Guide
You write a rule that should win. It doesn't. You add !important. Now something else breaks. Specificity fights are the most common source of CSS frustration — and most tutorials only teach half the picture. This guide covers the complete system, including :is(), :where(), @layer, CSS Nesting's hidden specificity trap, and how Tailwind, Vue scoped styles, and CSS Modules each handle specificity differently.
W
W3Tweaks Team
CSS calc() Explained: Dynamic Values Without JS
CSS
16 min
May 31, 2026
CSS calc() Explained: Dynamic Values Without JS
You can't write width: 100% - 32px in plain CSS — the browser doesn't know what 100% minus 32 pixels equals until layout time. calc() defers that calculation to the browser, solving it at render time when both values are known. No JavaScript needed.
W
W3Tweaks Team
CSS object-fit & object-position: Stop Stretching
CSS
11 min
May 30, 2026
CSS object-fit & object-position: Stop Stretching
You have a card grid where every thumbnail should be the same height. You set width:100% and height:200px on the images — and they all stretch and distort. The fix is two words: object-fit: cover. This guide covers all 5 values, the focal-point trick with object-position, and why object-fit sometimes silently does nothing.
W
W3Tweaks Team