Do custom CSS properties use one leading dash or two?

半世苍凉 提交于 2019-11-28 02:04:29
  • single leading dash is used for vendor prefixes
  • double leading dash is used for defining custom properties.

2 Defining Custom Properties: the '--*' family of properties

A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --foo. The <custom-property-name> production corresponds to this: it’s defined as any valid identifier that starts with two dashes.

An example from W3C:

:root {
  --main-color: #06c;
  --accent-color: #006;
}
/* The rest of the CSS file */
#foo h1 {
  color: var(--main-color);
}

It's worth noting that CSS variables are implemented in Firefox 31 and newer.

Custom properties use one dash, by convention followed by the renderer/software.

For example:

-webkit-box-shadow

-moz-box-shadow ...

But it seems that there is a new feature implementing two dashes, this might be interesting for you:

http://www.broken-links.com/2014/08/28/css-variables-updating-custom-properties-javascript/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!