Home Web Front-end CSS Tutorial An Interview With Elad Shechter on 'The New CSS Reset'

An Interview With Elad Shechter on 'The New CSS Reset'

Mar 18, 2025 am 11:17 AM

An Interview With Elad Shechter on

This interview explores Elad Shechter's innovative CSS reset project, "the-new-css-reset," a modern approach leveraging cutting-edge CSS features. Instead of simply presenting the code, we delve into the why behind its creation and the intricacies of its functionality.

The complete reset code is:

/*** The new CSS Reset - version 1.2.0 (last updated 23.7.2021) ***/

/* Remove all styles except 'display' */
*:where(:not(iframe, canvas, img, svg, video):not(svg *)) {
  all: unset;
  display: revert;
}

/* Preferred box-sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove list styles */
ol, ul {
  list-style: none;
}

/* Prevent images from exceeding container */
img {
  max-width: 100%;
}

/* Collapse table borders */
table {
  border-collapse: collapse;
}

/* Revert 'white-space' for Safari textareas */
textarea {
  white-space: revert;
}
Copy after login

Elad explains the need for a new reset, highlighting that existing resets rely on older CSS features. His approach leverages newer capabilities for a more efficient and valid reset. He contrasts his approach with Normalize.css (a gentler approach focusing on fixing browser inconsistencies) and Eric Meyer's CSS Reset (a more aggressive approach removing most default styles). Elad advocates using both Normalize.css and a hard reset, combining their strengths.

The core of the new reset lies in all: unset;. This powerful property resets all inherited properties to inherit and non-inherited properties to initial, effectively removing default browser styles. However, display is an exception. all: unset; sets display to inline which is undesirable. Therefore, display: revert; is used to restore the browser's default display value for each element, ensuring proper layout. The revert keyword intelligently retrieves the user-agent stylesheet's default display value if available, otherwise falling back to unset behavior.

The selector *:where(:not(iframe, canvas, img, svg, video):not(svg *)) targets nearly all elements, excluding those (like <iframe></iframe>, <canvas></canvas>, etc.) whose dimensions are best controlled via attributes rather than CSS reset, preventing unintended consequences. The :where() pseudo-class minimizes specificity, avoiding conflicts with project-specific styles. A separate :not(svg *) exclusion protects SVG elements' integrity.

The reset also includes opinionated styles like box-sizing: border-box, which, while not a browser inconsistency, is widely adopted as best practice. The removal of list styles (list-style: none;) is justified by the common use of lists for navigation where markers are unnecessary, despite the semantic implications.

Elad discusses future potential additions, driven by recurring needs in his projects. The max-width: 100%; rule for images is presented as a likely candidate. He also speculates on the impact of the upcoming Cascade Layers module, suggesting it could eliminate the need for specificity-reducing techniques like :where() by providing a layered approach to style overriding. This would allow for a cleaner separation of reset styles from project-specific styles.

The above is the detailed content of An Interview With Elad Shechter on 'The New CSS Reset'. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It&#039;s out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

Can you get valid CSS property values from the browser? Can you get valid CSS property values from the browser? Apr 02, 2025 pm 06:17 PM

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That&#039;s like this.

Stacked Cards with Sticky Positioning and a Dash of Sass Stacked Cards with Sticky Positioning and a Dash of Sass Apr 03, 2025 am 10:30 AM

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I&#039;d say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Comparing Browsers for Responsive Design Comparing Browsers for Responsive Design Apr 02, 2025 pm 06:25 PM

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

Using Markdown and Localization in the WordPress Block Editor Using Markdown and Localization in the WordPress Block Editor Apr 02, 2025 am 04:27 AM

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

See all articles