Inheritance and the all Property
Understand CSS inheritance rules and use the all property to reset inherited styles.
Inheritance and the all Property is a free CSS Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What is Inheritance?
Some CSS properties automatically pass their computed value down to child elements. This is inheritance. It saves writing the same rule for every element in a component.
Inherited Properties
Typically inherited: typography and text properties:
font-family,font-size,font-weight,font-stylecolorline-heightletter-spacingtext-alignvisibility- CSS custom properties
Non-Inherited Properties
Typically NOT inherited: box model and layout properties:
margin,padding,borderwidth,heightbackgrounddisplay,positionbox-shadow,transform
inherit Keyword
Force inheritance explicitly with the inherit keyword — useful for form elements that do not inherit font by default:
input, button, textarea, select {
font-family: inherit;
font-size: inherit;
color: inherit;
}initial Keyword
The initial keyword resets a property to its browser default initial value as defined by the CSS specification — ignoring inheritance and user-agent styles.
.reset-text {
font-size: initial; /* sets to medium */
color: initial; /* sets to black */
}unset Keyword
unset is context-sensitive:
- For inherited properties: acts like
inherit - For non-inherited properties: acts like
initial
It effectively "clears" a property to its natural state.
.clear-styles {
color: unset; /* inherits from parent */
margin: unset; /* resets to 0 (initial) */
}revert Keyword
revert reverts to the browser's user-agent stylesheet value — restoring what the browser would show by default, without any author styles. Useful for embedded third-party widgets.
.widget {
all: revert; /* undo all author styles */
}The all Property
The all property is a shorthand that applies a keyword to every CSS property simultaneously, except for direction and unicode-bidi.
.isolated-widget {
all: initial; /* reset everything to initial values */
}
.scoped-component {
all: revert; /* revert to browser defaults */
}Practical all: initial
Use all: initial when you need to create a completely isolated component that is not affected by global or parent styles:
.email-template-preview {
all: initial; /* start fresh */
font-family: Arial, sans-serif;
font-size: 14px;
}all: unset Pattern
Strip browser button styles for custom buttons without knowing all the relevant properties:
.custom-btn {
all: unset;
display: inline-block;
cursor: pointer;
/* now style from scratch */
}Inheritance and Custom Properties
CSS custom properties are inherited by default. This is what makes them powerful — a variable set on :root is available everywhere. Use @property { inherits: false } to make a custom property non-inheriting.
Quick Check
Which keyword resets a property to the browser's user-agent default rather than the CSS specification initial value?
Recap
Inherited properties pass values to descendants; non-inherited properties do not. The inherit, initial, unset, and revert keywords provide explicit control. The all property resets every property at once — powerful for isolated components and custom form elements.
Frequently asked questions
Is the “Inheritance and the all Property” lesson free?
Yes — the full text of “Inheritance and the all Property” is free to read here on the web, and the CSS Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO.
What will I learn in “Inheritance and the all Property”?
Understand CSS inheritance rules and use the all property to reset inherited styles. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start CSS Academy?
No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Inheritance and the all Property” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this CSS Academy lesson?
Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Specificity Calculation: Inline Style ID Class Element
- The Cascade: Origin and Order
- !important: When and Why Not
- Inheritance and the all Property