w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.52k stars 672 forks source link

[css-values] Request for New CSS Unit Proposal (pem Unit) #11051

Open softwaredevomar opened 1 month ago

softwaredevomar commented 1 month ago

Dear W3C Submissions Team, I, the undersigned, hereby submit the attached proposal for the introduction of a new CSS unit, pem, which stands for “parent element”. This proposal aims to enhance clarity, accessibility, and understanding in CSS by explicitly indicating that the size is relative to the parent element’s font size, similar to how rem indicates a relationship to the root element.

Please find the detailed submission document attached to this issue description. I believe this addition will significantly benefit the web development community by making CSS more intuitive, especially for new developers.

I look forward to your feedback and are available for any further discussions or clarifications needed. Submitted Materials.docx

Loirooriol commented 1 month ago

You basically want inherit(font-size) from #2864 For now we restricted it to custom properties, but it should still allow something like

@property --em {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --pem {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
* {
  --em: 1em;
  --pem: inherit(--em);
}
#foo {
  padding: 2--pem;
}