Skip to content

Overview of new CSS specs of interest #137

Open
@JayPanoz

Description

@JayPanoz

For the sake of transparency, I'm submitting a snippet of documentation on CSS specs that could be of interest in the context of user settings/overrides, and their impact.

The goal is to publish this overview and start a discussion.

As a reminder, a list of impactful specs was documented in ReadiumCSS back in the days.

There may be use cases that have been overlooked, or specs that flew under the radar and could have helped solve issues implementers encountered. It’s also a lot healthier to have the conclusions challenged whenever possible as that can also at least show there’s a need to clarify.

Logical Properties

This could help simplify internationalization by replacing physical dimensions (margin-top, padding-left, width, max-height, etc.) with axes (block and inline) tied to direction, text-orientation, and writing-mode.

In other words, the same styles could theoretically be used for LTR, RTL, and vertical writing.

However, the impact is limited as only a handful of ReadiumCSS’ declarations (mainly but not all “vertical” modules and submodules) would benefit from it, and it wouldn’t help get rid of CJK and RTL stylesheets as they also differ in user settings.

MDN docs

Support : Chrome 89, Safari 15, FF 66 (late 2021)

Container queries

This has no impact on ReadiumCSS. While it could be used to fine-tune the default stylesheet for unstyled publications – and font-size normalize module –, it doesn’t make much sense considering these were designed with small screens in mind.

Container queries may be more interesting to authors/publishers, given they can serve as media queries of sorts in the multicolumn context, something they have not been able to target reliably so far.

MDN Docs

:has pseudo-class

This pseudo-class allows to style an element based on its descendants, but can also be combined with CSS selectors like +, ~, > or other pseudo-selectors like :not.

In theory, it could be primarily used to handle exceptions when applying overrides/user settings, although use cases are unknown at this point.

It’s important to note it could be used as a progressive enhancement, but create inconsistencies as a side-effect e.g. app handling things differently based on the browser/OS version used, which could in turn result in additional bug reports.

MDN docs

Support: Chrome 105, Safari 15.4, FF 121 (late 2023)

Comparison functions

The comparison functions of min(), max(), and clamp() compare multiple calculations and represent the value of one of them.

The major use case is fluid design, including fluid typography, which implies these functions can be very useful for authors/publishers but not so much for reading systems.

Since we don’t have access to the authors/publishers’ value, this can’t be used to get rid of the font-size normalisation required for the font size user setting. Indeed, one could have imagined using min() for elements’ font-size to force some sort of normalisation only if the value is set using absolute units in authors/publishers’ stylesheet. But we can’t retrieve this value using CSS…

Another use case could be to force a floor or a ceiling for font-sizes when applying font-size normalisation and changing the font-size so that headings are not too huge or other elements too small. However, that would imply some UX weirdness as increasing/decreasing font-size would result in an inconsistent result – with headings’ size not increasing for instance. This is probably not what users expect.

MDN Docs

Support: Chrome 79, Safari 13.4, FF 75 (mid 2020)

Cascade layers

Cascade layers offer to create separated cascades you can access anywhere in the files, and to layer them in the order we want. This doesn’t mean that each layer is scoped though, it’s more of an organization tool, not a scoping mechanism.

In theory, this could have ended the “before/after mechanism” ReadiumCSS is relying upon by using layers instead, and provide a single dist stylesheet.

But this wouldn’t save Reading Systems from doing some work since un-layered styles always have the priority on layered styles. In other words, they would have to layer authors/publishers’ stylesheets.

In practice, this is consequently just an alternative option with its own pros and cons. It doesn’t really solve this issue more efficiently, only in a different manner and doesn’t offer more reliability (no scoping) nor ease-of-implementation (Reading Systems don’t get rid of something, they replace option A with option B).

MDN Docs

Support: Chrome 99, Safari 15.4, FF 97 (early 2022)

Metadata

Metadata

Assignees

No one assigned

    Labels

    2024 UpdateNew discussions, issues and requests triggered by the 2024 updatedocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions