CSS Declarations
Learn how CSS declarations define the presentation applied by a style rule and how property values form the rule's effect.
Basic
What a declaration does
A CSS declaration specifies a property and the value assigned to that property. Declarations are the part of a style rule that describes the presentation to apply to elements matched by its selector.
|
|
Here,
color and
margin-block are properties, and each value follows the property name after a colon.
Declarations inside a rule
A declaration block can contain multiple declarations. Each declaration is terminated by a semicolon, allowing several properties to contribute to the same style rule.
|
|
Property values matter
Output
Ready to run.
Quick check
What part of `color: darkslateblue` is the property?
A property does not accept an arbitrary value. Each CSS property defines the kinds of values it accepts, and the value determines the result of the declaration when the rule applies.
|
|
Every rule you will ever write is made of these parts. When you are ready, take the CSS Declarations quiz.
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.