CSS Syntax
CSS follows a specific syntax to define how elements should be styled. The basic syntax consists of a selector and a declaration block.
CSS Rule Structure:
- Selector: This determines which HTML element(s) the style will apply to.
- Declaration Block: This contains one or more declarations, which specify what style to apply. Each declaration has a property (the style you want to change) and a value (what you want to set that property to).
CSS
x
selector {
property: value;
}
Explanation of Code:
- The selector is
p
, which selects all<p>
(paragraph) elements. - The declarations are
color: blue;
andfont-size: 16px;
, which change the text color to blue and the font size to 16px.
CSS
p {
color: blue;
font-size: 16px;
}