Which syntax defines a CSS custom property?

Prepare for the uCertify CIW Advanced HTML5 and CSS3 Specialist Exam. Dive into essential topics with flashcards and multiple-choice questions. Enhance your understanding with hints and explanations for each question. Pass your exam confidently!

Multiple Choice

Which syntax defines a CSS custom property?

Explanation:
Defining a CSS custom property uses a name that begins with two hyphens, followed by a colon and the value. This two-dash prefix is what marks it as a custom property, so an example declaration would be --name: value;. The declaration ends with a semicolon and is placed inside a selector (often on :root for global scope). To actually use that value, you retrieve it with var(--name). The other options don’t define a custom property: var(--name) is how you read the value, not declare it; name--: value uses an invalid property name format; $name: value comes from CSS preprocessors like Sass, not vanilla CSS.

Defining a CSS custom property uses a name that begins with two hyphens, followed by a colon and the value. This two-dash prefix is what marks it as a custom property, so an example declaration would be --name: value;. The declaration ends with a semicolon and is placed inside a selector (often on :root for global scope). To actually use that value, you retrieve it with var(--name).

The other options don’t define a custom property: var(--name) is how you read the value, not declare it; name--: value uses an invalid property name format; $name: value comes from CSS preprocessors like Sass, not vanilla CSS.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy