CSS
Modern CSS techniques for better layouts, responsive interfaces, cleaner stylesheets, and solving everyday front-end development challenges.
Browse 97 articles in this topic. View all topics.
- How margin-inline follows the text direction
CSS margin-inline sets margins along the inline axis, making spacing work across writing modes and text directions.
- What CSS color-scheme Actually Does
Tell the browser which color schemes your page supports and let native controls match light or dark mode.
- Native CSS Nesting Without Sass
Use native CSS nesting to keep related selectors and media queries together without turning the stylesheet into a maze.
- Fluid Typography and Spacing With CSS clamp()
Use CSS clamp() for fluid typography and spacing. Combine relative and viewport units, set readable limits, and keep layout changes separate from sizing.
- Aligning Nested Layouts With CSS Subgrid
Use CSS subgrid when items inside a nested grid need to align with tracks from the parent grid.
- Filtering Content With the CSS :has() Selector
Use CSS :has() and checkboxes to build a small content filter without JavaScript.
- CSS Grid or Flexbox? Choose by layout direction
A practical way to choose between CSS Grid and Flexbox based on the layout you are building.
- Set up Tailwind CSS in Hugo
Set up Tailwind CSS in a Hugo project with the Tailwind CLI or a PostCSS build step.
- CSS :has() Can Select a Parent
CSS :has() selects an element based on its children or nearby siblings, with examples and historical browser-support context.
- Let Safari Draw the Apple Pay Button
Let Safari draw the correct Apple Pay button with CSS, including button types, styles, and an older-browser fallback.
- Invert Colours With One CSS Filter
Use CSS filter invert() on an element or page, and understand why partial inversion is not simply a lighter version.
- Make an Iframe Responsive With CSS
Keep videos, maps, and other iframes responsive with an aspect-ratio wrapper and a small amount of CSS.
- Nesting Media Queries in CSS
Combine multiple conditions by nesting CSS media queries at the root of a stylesheet.
- Mixing percentages and pixels with CSS calc()
Use CSS calc() to combine percentages and fixed lengths in practical, responsive layouts.
- Dark mode images without JavaScript
Serve separate light and dark images with the picture element and prefers-color-scheme.
- Styling list markers with CSS list-style
Understand the list-style shorthand and its type, position, and image values with a small CSS example.
- Dark mode for SVG favicon
Use CSS inside an SVG favicon to give it separate colours for light and dark mode.
- A one-line CSS layout debugger
Outline every element on a page in a different colour with one line in Chrome DevTools.
- Styling the hr Element With CSS
Style the hr element with solid, dashed, gradient, and ornamental dividers, while keeping semantic breaks, spacing, colours, and dark mode consistent.
- Adding dark mode with prefers-color-scheme
Add a dark colour scheme that follows the visitor's system preference, using CSS and custom properties.