可以说“CSS变量”代替“自定义属性”。
It is ok to say "CSS variables" instead of "custom properties"

原始链接: https://blog.kizu.dev/css-variables/

在疲惫的TPAC 2025会议之后,作者反思了CSS术语。核心观点是:将“CSS变量”与官方名称“自定义属性”互换使用是完全可以接受的。 虽然官方模块名称是“CSS用于级联变量的自定义属性”,并且其URL使用“css-variables”,但作者认为它们*是*变量——特别是,可以随CSS规则动态变化的级联变量。他们强调了诸如动画能力、对视口/容器变化的响应以及显式类型化(通过@property)等特性。 作者俏皮地声称CSS(以及HTML!)确实是编程语言。受到最近CSSWG F2F实验成功的鼓舞,他们计划在未来的文章中详细阐述这个想法。最终,这篇文章只是由疲惫引发的一个快速想法,倡导在CSS社区内使用舒适易懂的语言。

相关文章

原文
Published on:
Categories:
CSS Variables 9, CSS 85
Current music:
Rökkurró
Sjónarspil
Current drink:
Ceylon Tea

TPAC 2025 just ended, and I am positively tired. Attending it remotely, my sleep schedule is chaotic right now. I have many ideas for CSS-related posts in my list of ideas for November, but almost all of them require at least some amount of research and crafting demos.

Well! I found one note that I wanted to expand on, and which sounds tiny enough to be able to finish it in my altered state.

Let me repeat the title of this post: it is OK to say “CSS Variables” instead of (or Alongside) “Custom Properties”.

I won’t say that this is something contentious, but it was always mostly a thing where I always stumbled a bit before continuing using the terminology.

The official name of the corresponding CSS module is “CSS Custom Properties for Cascading Variables”. It’s URL’s slug is css-variables.

They are variables. More specifically: cascading variables. They change with the cascade: when different rules match, values can be overridden and change.

We can have animations that involve custom properties, or custom properties with values based on the viewport, containers, or something else — dynamic, responsive values that can vary for multitudes of reasons.

They are also custom properties, and even the more property-like when using @property. They can also be explicitly typed, while the rest of CSS is often typed implicitly. But — typed, unlike some other “programming languages”.

Ah, yes, CSS (and HTML) are programming languages, and anyone thinking otherwise is wrong. The best programming languages, according to me, by the way.


Oh, I am tired. But also right after finishing this last day night of CSSWG F2F, I successfully experimented a bit with one ongoing idea of mine, and now planning to write a proper nice article, for my main site, like I sometimes do. Stay in touch.

联系我们 contact @ memedata.com