Declaring CSS Styles
Notes:
Style: Distinctive appearance
Distinguish one element from other elements
Ex: color, font-size, border, border-style etc…..
Style Rule: styles are properties in CSS
property-name : value
Ex:
color : red
background-color : yellow
font-family : Arial
font-size : 24pt
Declaring style rules: property-name : value ;
Ex:
color : red;
background-color : yellow;
font-family : Arial;
font-size : 24pt;
Declaration list:
color : red; background-color : yellow; font-family : Arial; font-size : 24pt;
Declaration list is a collection of style rules separated by semicolons. OR Declaration list is a list of style rule declarations.
CSS Style rule set: set of rules (declaration list)
Syntax:
selector
{
declaration list;
}
Ex:
p
{
color : red;
background-color : yellow;
font-family : Arial;
font-size : 24pt;
}
Interview Questions:
1. Correct syntax of declaring a CSS rule is ___________________
a. property-name = value ;
b. property-name : value
c. property-name = value
d. property-name : value ;
Answer: d