Style Declarations
A given HTML element is styled by CSS with style declarations.
A CSS style declaration is a block of code built with property/value pairs consisting of properties, colons, values and ending semicolons. The ending semicolon is optional for the last property/value pair.
An inline CSS style declaration must not be confined within any brackets.
Internal and external CSS style declarations must be confined within curly brackets and preceded by a selector.
p {
font-size: 24px;
color: red
}
The name of properties are strictly defined by CSS.
The CSS value data types are also strictly imposed by CSS. The value data types include:
-
keywords (e.g.
inherit
,blue
), -
integers and/or floats with units (e.g.
42px
,23%
), -
hexadecimals, RGBA, HSL, HSLA for colors.
CSS style declaration can define among others the following features of an element:
-
positioning (x-axis, y-axis and z-axis),
-
size,
-
shape,
-
borders,
-
background color and/or picture,
-
text alignment, and
-
font family and color.
When style declarations have the same specificity associated the last defined style declaration is applied.