CSS Basics

Cascading Style Sheets (CSS) is a stylesheet language we use to style an HTML document. CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.

CSS Ruleset

CSS rules is composed of a selector and a declaration block. The declaration block can have one or multiple declarations. Each declaration has a property and its value.

Selector

This is used to select the element(s) you want to style. In this example, we are selecting all the p elements in the HTML document.

Declaration Block

A selector is followed by a declaration block. The curly braces { } defines the beginning and ending of a declaration block.

Declaration

Declarations should be put Inside the curly braces. They can define how the selected HTML element will be displayed. Each declaration ends with a semicolon ;.

Properties

The first part of a declaration (before the colon : ) defines which property of the selected element you want to style. In this example, we are changing the color of all the p elements.

See a list of CSS properties here: https://www.w3schools.com/cssref/default.asp

Property Value

To the right of the property (after the colon : ) is the property value. This chooses one out of many possible appearances for a given property. In this example, the color of the p elements will be displayed red, which is one of the many values that can be applied to the color property.

back