liveBook · Manning

Cascade

As explained in WordPress Power Toolkit: Harness AI to build next-level websites

The CSS cascade is the rule-resolution process that determines which CSS declarations apply when multiple declarations match an element.

Why did a heading turn blue when you set it to red? More than one CSS declaration can set the same property. The cascade determines which value the browser uses. When a property is repeated within one style sheet, the lower declaration overrules the earlier one. section 7.2.4

h1 {
    color: red;
}
h1 {
    color: blue;
}

Both rules set the color of h1 headings. Blue appears because its declaration comes later in the style sheet. section 7.2.4

For a WordPress site, picture four levels from earliest to latest:

  • Browser defaults provide a starting appearance. section 7.2.5
  • The theme’s CSS can overrule those defaults. You can view it under Appearance > Theme File Editor, but do not modify the theme files. section 7.2.5
  • Your site-wide CSS, entered under Appearance > Customize > Additional CSS, comes next. section 7.2.5
  • Inline CSS, placed in a page’s HTML, targets a local area and is the final level in this four-level picture. section 7.2.5

Find out why a style lost

Right-click the page and choose Inspect. Select the heading in the HTML pane, then check its rules in the Styles pane. A crossed-out property has been overruled. You can edit a value there to see the visual result immediately before changing your site’s CSS. section 7.3

Choose the reach of a change deliberately: site-wide CSS is useful for a consistent look, while inline CSS can style just a word, paragraph, or page area. section 7.2.5 section 7.5

How WordPress Power Toolkit: Harness AI to build next-level websites covers it

How deep it goes
Explains repeated properties through a heading-color example and a four-level WordPress model, without detailing further resolution rules.
Examples
Uses competing heading colors, a four-level cascade illustration, inline color snippets, and crossed-out properties in the Inspector.
What it assumes
Introduces selectors and property-value pairs through examples; assumes access to WordPress administration screens for the suggested site changes.
What you can do after
Diagnose/debug with it by inspecting overridden CSS properties and testing visual changes in the browser’s Inspector.
How it connects
Connects CSS selectors and declarations to browser defaults, WordPress themes, inline CSS, CSS scope, and browser developer tools.

Also explained in

Compare how 5 books explain cascade →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of WordPress Power Toolkit: Harness AI to build next-level websites. The section links point to the parts of the book it draws on.