W3C home > Mailing lists > Public > www-html@w3.org > March 2017

Re: CSS class parameters

From: Alan <mmfunkyd@hotmail.com>
Date: Wed, 29 Mar 2017 15:33:58 +0000
To: "www-html@w3.org" <www-html@w3.org>
Message-ID: <BL2PR17MB08516B99AF4FC9EE60503952C4350@BL2PR17MB0851.namprd17.prod.outlook.com>
Apologies, but I actually meant to post this to www-style, since it would largely be CSS that needs to cope. I created a new post over there, for those interested in discussing.

On Mar 29, 2017, at 01:51, Alan <mmfunkyd@hotmail.com<mailto:mmfunkyd@hotmail.com>> wrote:

Has the idea of adding the ability to parameterize classes within the DOM ever been considered? I have searched the archives and the web, but I haven’t been able to locate any past conversations about this.

Basically, the idea would be to allow CSS rulesets to be templated, by providing a parameter to a class in the markup. So say I had a progress bar. In this imagined syntax, I could pass in the percentage completion as a parameter:


<div class=“progress-bar”>
  <div class=“progress-bar-completion(50)”>


.progress-bar {
  background-color: pink;
  height: 5px;
  width: 400px;

.progress-bar-completion(percentage) {
  background-color: red;
  height: 100%;
  width: `percentage`%;

This could be very helpful in front-end paradigms where the dynamic logic mediates styling via markup.

Here, the progress bar effect requires the combination of several rules. Sure, the width could be set in the `style` attribute, but then the effect becomes lexically split between the static and dynamic parts. Parameterization also opens the door to dynamism in CSS features that aren’t available in the `style` attribute.

I’m very curious whether this has been discussed before.


Received on Wednesday, 29 March 2017 15:34:39 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 29 March 2017 15:34:40 UTC