liveBook · Manning

Declaration

As explained in Tiny CSS Projects

A CSS declaration consists of a property name, a colon, and a property value specifying one styling instruction.

A CSS declaration combines a property name, a colon, and a property value to specify one styling instruction. In h1 { color: crimson; }, color: crimson is the declaration. Declarations appear inside CSS rules alongside a selector, which identifies the elements to style. section 1.3.2 section 1.8

Listing 1.2 Embedded CSS
<!DOCTYPE html>
<html lang="en">
 <head>
   ...
  <style>
   h1, h2, h3, h4, h5, h6 {
    color: crimson;
   }
  </style>
 </head>
 <body>
  ...
 </body>
</html>

Use the embedded CSS listing to see several declarations styling all heading elements through one grouped rule. section 1.3.2

Several declarations in one rule

h1 { color: red; font-size: 16px; font-family: sans-serif } Each line changes a different aspect of the heading. The final declaration does not require a semicolon, although earlier declarations are separated with semicolons. section 1.7.2

Keep these browser and maintenance behaviors in mind:

  • Write property names and values in the supported American English spellings; invalid declarations are ignored while other valid declarations continue to apply. section 1.3.2
  • Choose multiline or single-line formatting according to readability and team preference; neither style is inherently correct. section 1.7.2

How Tiny CSS Projects covers it

How deep it goes
Explains declaration syntax, browser handling of invalid values, formatting choices, and optional final semicolons.
Examples
Uses heading rules that set color, font size, and font family, including a grouped rule for multiple heading elements.
What you can do after
Apply it via CSS by writing valid property-value pairs inside rules and choosing readable declaration formatting.
How it connects
Connects declarations to CSS rules, selectors, properties, property values, and specificity.

Also explained in

Compare how 4 books explain declaration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.