Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Basics of CSS Structure

CSS consists of rules that define how to style certain HTML elements with certain attributes in certain ways.

To select specific HTML elements, CSS uses selectors, and assigns styles through properties with specified values.

Basic CSS Structure
selector {
property: value;
}

For example, the following code applies the color property to an h1 tag to change the text color to red.

CSS Example
h1 {
color: red;
}

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

A semicolon ; is always placed at the end of a value to indicate the end of the line.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.