W3C home > Mailing lists > Public > public-css-archive@w3.org > January 2021

Re: [csswg-drafts] Parameters typed on CSS rules ? (#5824)

From: Sebastian Zartner via GitHub <sysbot+gh@w3.org>
Date: Fri, 01 Jan 2021 18:43:32 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-753364311-1609526611-sysbot+gh@w3.org>
If I unterstand your proposal correctly, then the [`attr()` function](https://drafts.csswg.org/css-values-4/#attr-notation) might already cover your use case.

It keeps the selectors untouched but references the values defined in element attributes.

Here are some examples:
.selector {
  opacity: attr(data-opacity number); /* numeric value */
  font-size: attr(data-font-size length); /* length value */
  background-color: attr(data-bgcolor color, white); /* color value with white as fallback */
  background-image: url(attr(data-bgimage url)); /* url value */

Though note that this function is still under discussion due to [security concerns](https://github.com/w3c/csswg-drafts/issues/5092) among other things.

Happy New Year! 🥳 🍾 


GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5824#issuecomment-753364311 using your GitHub account

Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 1 January 2021 18:43:35 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:25 UTC