Css - Rule (Set|Declaration)

1 - About

In a CSS file, your write several rules to define your presentation.

A rule set (also called “rule”) consists of:

3 - Syntax


selectorList { 
         property: value; 
         [more property:value; pairs] 
}

where:

  • selectorList

selector[:pseudo-class] [::pseudo-element] [, more selectorlists]

4 - Example

The CSS rule


h1 { 
    color: red;
    font: Consolas;
}

where:

The HTML


<h1>This text will be red with the font Consolas</h1>

The result

5 - Property Order

The property may be laid out in any order but from a reading perspective, there is properties that are more important than other.

The code guide proposes an order by type of property:

  • Positioning comes first because it can remove an element from the normal flow of the document and override box model related styles.
  • The box model comes next as it dictates a component's dimensions and placement.
  • Everything else takes place inside the component or without impacting the previous two sections, and thus they come last.


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap