CSS Syntax
CSS
Selectors and style declarations are what CSS syntax is all about.
CSS syntax
➔ CSS syntax consists of two parts selectors and style declarations.
➔ The function of selectors is to select the elements to which the CSS style will be applied.
➔ The function of the declaration part is to declare the CSS style inside curly braces that will be applied to the selected elements.
➔ A property and value pair inside curly braces separated by colons is called a CSS declaration, whereas multiple CSS declarations are separated by semicolons inside the same curly braces.
Click on the "Try it Now" button to see how it works.
Explain Code
Here, p is a selector that selects the HTML elements to which you want to apply the style.
color is a CSS property and red is the property's value, font-style is a CSS property and italic is one of the property's values.
Curly braces { } are mandatory to enclose all CSS code.