Making WordPress.org

Opened 4 weeks ago

#8012 new defect (bug)

Incorrect use of "elements" instead of "blocks" in Theme Handbook example for nested element styles

Reported by: tomdevisser's profile tomdevisser Owned by:
Milestone: Priority: low
Component: Handbooks Keywords:
Cc:

Description

Issue Description

The Theme Handbook page on applying styles in theme.json contains an incorrect example under the “Styling elements nested in blocks” section. The example uses "elements" as the top-level key where it should be "blocks" when targeting specific core blocks like core/pullquote.

URL of the Page with the Issue

https://developer.wordpress.org/themes/global-settings-and-styles/styles/applying-styles/#styling-elements-nested-in-blocks

Why is this a problem?

This typo can confuse theme developers trying to target nested elements inside blocks. Using "elements" as the top-level key in this context is invalid and will not apply any styles, potentially leading to wasted debugging time and incorrect assumptions about how theme.json works.

Suggested Fix

Update the example by replacing the top-level "elements" key with "blocks", as shown below:

{
  "version": 2,
  "styles": {
    "blocks": {
      "core/pullquote": {
        "typography": {
          "fontSize": "2.25rem"
        },
        "elements": {
          "cite": {
            "typography": {
              "fontSize": "max( 50%, 1.5rem )"
            }
          }
        }
      }
    }
  }
}

Also consider updating the example to use version 3 of the schema for consistency with current standards.

Change History (0)

Note: See TracTickets for help on using tickets.