JavaScript Tutorial

CSS Syntax

A CSS rule set contains a selector and a declaration block.

 

Explanation:-

The above whole block with {}, is a declaration block. Here, p is the selector, color is the property, and "#333333" is the value of this property.

  • Selector: Selector indicates the HTML element you want to style. It could be any tag like <p>,<h1>, <title>, etc.
  • Declaration Block: The declaration block can contain one or more declarations separated by a semicolon.
  • Property: A Property is a type of attribute of an HTML element. It could be color, border etc.
  • Value: Values are assigned to CSS properties. In the above example, value "#333333" is set to color property.

Case Sensitivity in CSS

CSS property names and many values are not case-sensitive. Whereas, CSS selectors are usually case-sensitive, for instance, the class selector .headerblock is not the same as . headerBlock.

Therefore, to be safer, you should assume that all components of CSS rules are case-sensitive.

Go back to Previous Course