CSS Syntax
The
general syntax of CSS consists of three parts namely, selector, property, and
value. A selector is an HTML element for which you want to specify the style or
the formatting instruction. A property of a selected element is a CSS property
that specifies the type of the style to be applied to the selector. CSS allows
controlling the appearance of the content by providing various properties.
These properties include text properties, positioning properties, font properties,
color properties, and so on. A value refers to the value of the CSS property. A
CSS property can have multiple values. For example, the values of the color property
include red, green, yellow, and so on. The property and the value for a
selector are separated with a colon (: ). They are enclosed within the
curly brackets ({}) that is known as the declaration
block.
You
can have various combinations to specify rules for HTML elements. First, you
can specify multiple property-value pairs for a selector, which are separated
by a semicolon (;) within the declaration block.
Second, you can specify multiple selectors for a single property by grouping
the selectors. To group the selectors, the selectors are separated by commas followed
by a declaration block of properties and values. Third, you can specify properties
for multiple selectors. Here, the comma-separated selectors are followed with multiple property-value pairs.
for multiple selectors. Here, the comma-separated selectors are followed with multiple property-value pairs.