Style Declarations in CSS

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.

<p style="font-size: 24px; color: red">...</p>

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.

We use cookies and similar technologies to enhance the quality of services, maintain statistics and adjust marketing content. You will find more information in the Cookies Policy.

By clicking OK you grant consent to processing of your personal data by us and our Trusted Partners with the purpose of maintain statistics and adjustment of the marketing content pursuant to the Privacy Policy. If you wish to not grant that consent and/or limit its extent click Settings.