본문으로 건너뛰기

Understanding the Basic Structure of CSS

Understanding the Basic Structure of CSS

Basic Structure: Selectors, Properties, Values

CSS is composed as follows:

CSS Basic Structure
selector {
property: value;
}

Just as a printer applies a specific color to each coordinate, CSS has rules for styling which HTML element (selector) with what (property) in which way (value).

  • Selectors: Choose the HTML element to which you want to apply styles.

  • Properties and Values: Specify what properties (for example: color, font size) you want to apply to the selected element and how (for example: red, 16px).

For instance, if you want to apply the color red to the previously defined h1 tag, you would write the following CSS:

CSS
h1 {
color: red;
}

Here, h1 is the selector, color is the property, and red is the value.

You must always append a semicolon (;) at the end of the "value" to indicate that the line has ended.