Properties and Values
Each declaration needs a real property and a value of the type that property accepts, or the browser silently ignores it.
Inspect a rejected declaration and identify whether its property or value is invalid.
You write colour: green; and the prices stay black. No warning, no error, just nothing. CSS is forgiving in a way that hides mistakes: if the browser does not recognise a property or a value, it ignores that declaration and moves on.
The rule
Known property, valid value, or the browser quietly skips it.
Properties come from a fixed list defined by the CSS standards: color, background-color, font-size, margin, width and several hundred more. They are lower case, use hyphens between words, and use American spelling. You cannot invent one.
Values must fit the property. The common kinds are:
- Keywords: plain words the property understands, such as
bold,center,none,auto. - Lengths: a number glued to a unit, such as
16px,1.5rem,2em,50%. - Numbers with no unit, for properties that take them, such as
font-weight: 700orline-height: 1.5. - Colours, as names (
teal), hex (#0a7f5a), or functions such asrgb(10 127 90).
Two unit rules catch almost everyone:
- No space between number and unit.
16pxis a length;16 pxis invalid. - Zero needs no unit.
margin: 0is fine, but any other bare number where a length is needed, likewidth: 20, is invalid.
.dish h3 {
font-size: 1.25rem; /* length */
font-weight: 600; /* number */
text-align: center; /* keyword */
color: #1d3557; /* colour */
}