[csswg-drafts] [css-cascade][CSSOM] Protected properties (#13470)

Crissov has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade][CSSOM] Protected properties ==
Reading up on the current state of two-value syntax in the `display` property again recently, reminded me of a thought I first had a couple of years ago: 
Should CSS introduce *write-protected, read-only properties* which have a standardized name, whose value cannot be set directly (neither in stylesheets nor by scripts), but can be retrieved via scripting?

[CSS](https://drafts.csswg.org/css-cascade/#value-stages) currently considers a _property_ (of an element or box) as something that always exists in a default state and an author can explicitly assign a value to. 
A protected property would be special in that it could not be _declared_, but – I think – it would be _cascaded_ and therefore _specified_, so it also was _computed_, possibly becoming _used_ and _actual_.
[CSSOM](https://drafts.csswg.org/cssom/#css-declaration-blocks) allows scripts to access (i.e. read and usually also write) values by reading a _serialized_ (computed or used) value with [`getComputedStyle()`](https://drafts.csswg.org/cssom/#extensions-to-the-window-interface) or [`getPropertyValue()`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue ) and updating or by writing new values with [`setProperty()`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty) – or with their camel-cased and dashed attribute aliases; and also by deleting values with [`removeProperty()`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty). Note that while [CSS Declaration Block](https://drafts.csswg.org/cssom/#css-declaration-blocks) has a _readonly flag_, the [CSS Declaration](https://drafts.csswg.org/cssom/#css-declarations), which is not exposed as an object, has not and then would probably need one. 

Protected (or private?) properties would mostly be used with properties that accept multiple values and might become shorthand properties in a later level. The protected properties would work as the anticipated longhands. The danger, of course, is that editors would then feel more compelled to simply turn those former protected properties into longhands instead of exploring alternative solutions, e.g. `display-inside`/`-outside` vs. `display-model`/`-role`, to avoid the introduction of (partial) aliases. 

The concept could also be used by properties that are helpful or systematic to specify but should only be settable by the browser, never by authors and users, due to implementation details for semantics of the host document language, e.g. something like:

~~~~ css
/* browser default stylesheet for HTML */
img[src][alt] {
  display-model: replaced;
  content-image: attr(src type(<url>));
  content-text: attr(alt);
  content-size: target-size(attr(src type(<url>)));
}
a[href] {
  content-link: attr(href type(<url>));
}
title {
  env-set: title content();
}
[id] {
  target-set: attr(id type(<ident>));
}
~~~~

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13470 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 9 February 2026 16:52:42 UTC