• Aline K.

    (@titelala)


    The issue has already been reported regarding links, but the :root :where(…) selectors that appeared on WP 6.6 are a huge problem for global font styles. :root :where(body) has stronger specificity than the regular body selector. Same for any tag selector –?p, h2, a

    Because of that, the global typographic styles that I declared in my theme are all overrided and it affects every text element on the website, not just blocks.

    For example, this will be applied instead of the styles I declared for h2 in my theme:

    :root :where(h2) {
    font-family: var(--wp--preset--font-family--source-serif-pro);
    font-size: var(--wp--custom--typography--font-size--lv-2);
    font-weight: 700;
    line-height: var(--wp--custom--typography--line-height--small);
    }

    As a custom theme designer and developer, this means that I should edit every theme I ever created to replace regular selectors. This is of course highly annoying.

    I really don’t understand why this decision was made, and I hope there will be a rollback – or an efficient fix –?on this in a future release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can read more about the “why” behind the change here: https://make.www.ads-software.com/core/2024/06/21/wordpress-6-6-css-specificity/

    If you’re styling h2 in theme.json, it should override the default styles. For example:

    "styles": {
        "elements": {
            "h2": {
                "typography": {
                    "fontSize": "your-font-size-reference"
                }
            }
        }
    }
    joshuavb

    (@joshuavb)

    Echoing what @titelala has said here, this is affecting our clients’ websites across the board and is requiring us to rollback to 6.5.

    WP Core updates should not require us to charge clients for an update to their code base to work – extremely intrusive and unwelcome change.

    Edit: we have now rolled back clients to 6.5 and have turned off automatic updates for the time being. Hoping that this can be reviewed and addressed in some way for 6.6.1, it’s been a long time since I saw a Core update that so heavy-handedly affected so many sites at a visual level.

    • This reply was modified 3 months ago by joshuavb.

    This seems to be resolved in 6.6.1, confirmed by a few colleagues as well – although I can’t find it mentioned in the 6.6.1 changelog.


    @greenshady Is it possible to know how this was addressed? It seems to be resolved across the board with the latest version. I just can’t find where the changes are recorded.

    Looks like it went in here: https://github.com/WordPress/gutenberg/pull/63403

    It looks like it removes :root :where() with top-level element selectors that don’t have a class attached to them.

    Amazing news, thanks so much for confirming @greenshady.

    Appreciate everything you and the team do to make our development lives easier!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.