CSS Academy · Lesson

Inheritance and the all Property

Understand CSS inheritance rules and use the all property to reset inherited styles.

Lesson 4 of 413 steps

Inheritance and the all Property is a free CSS Academy lesson on CoddyKit. This is 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, and your progress syncs across the web and the CoddyKit app. The CSS Academy course includes 4 lessons in total.

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-style
  • color
  • line-height
  • letter-spacing
  • text-align
  • visibility
  • CSS custom properties

Non-Inherited Properties

Typically NOT inherited: box model and layout properties:

  • margin, padding, border
  • width, height
  • background
  • display, position
  • box-shadow, transform

inherit Keyword

Force inheritance explicitly with the inherit keyword — useful for form elements that do not inherit font by default:

<div style="font-family: Georgia, serif; font-size: 20px; color: darkred;">
  <input type="text" placeholder="Inherits font/color" />
  <button>Button inherits too</button>
  <textarea>Inherits</textarea>
  <select><option>Option A</option></select>
</div>

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.

<div style="font-size: 30px; color: tomato;">
  <p>Normal text inherits large tomato-colored style from its parent.</p>
  <p class="reset-text">This text resets to browser defaults (initial) — medium size, black color.</p>
</div>

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.

<div style="color: tomato;">
  <p style="margin: 40px;">Normal paragraph — keeps its large margin, inherits tomato color.</p>
  <p class="clear-styles" style="margin: 40px;">Unset paragraph — color unset (still inherits tomato), margin unset (resets to 0).</p>
</div>

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.

<div style="color: tomato; font-family: Georgia, serif;">
  Ancestor style is tomato serif text.
  <div class="widget">This widget uses "all: revert" to fall back to the browser's user-agent defaults, undoing author styles.</div>
</div>

The all Property

The all property is a shorthand that applies a keyword to every CSS property simultaneously, except for direction and unicode-bidi.

<div style="color: tomato; font-family: Georgia, serif; padding: 12px; background: #eee;">
  <div class="isolated-widget">all: initial — resets everything to spec defaults</div>
  <div class="scoped-component">all: revert — resets to browser UA defaults</div>
</div>

Practical all: initial

Use all: initial when you need to create a completely isolated component that is not affected by global or parent styles:

<div style="color: tomato; font-family: Georgia, serif; font-size: 28px;">
  Page context — large serif tomato text
  <div class="email-template-preview">Email preview — isolated with all: initial, then restyled with Arial 14px.</div>
</div>

all: unset Pattern

Strip browser button styles for custom buttons without knowing all the relevant properties:

<button class="custom-btn">Custom button styled from scratch using all: unset</button>
<button>Default browser button for comparison</button>

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.

Free to start

Learn CSS with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
40
Lessons
159

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. 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. The CSS Academy course includes 4 lessons in total.

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, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

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

  1. Specificity Calculation: Inline Style ID Class Element
  2. The Cascade: Origin and Order
  3. !important: When and Why Not
  4. Inheritance and the all Property
← Back to CSS Academy