We use cookies to enhance your experience on the site
CodeWorlds

CSS Rules

We're just beginning your journey toward mastering the art of styling text on web pages. You're already familiar with basic elements like headings and paragraphs. In the following modules of this course, we'll teach you how to manipulate font weight, choose the right font family, modify text style, adjust line and letter spacing, align text, and introduce other visual effects.

Earlier you noticed that CSS has its own specific syntax. In the spirit of continuing the HTML learning process from the heading, we'll start our text styling adventure from that very element. Many practical exercises await us, through which you'll gain experience and confidence in coding. Let's be inspired by the methods of ancient Egypt, where the principle of learning by doing was followed.

1<h1>Text</h1>

And now let's color this heading red:

1h1 {
2  color: red;
3}

Line 1 - selector - we define which element the rule should apply to, Line 2 - CSS declaration - property (color) and value (red) - specifies how the paragraph will look, Line 3 - closing curly brace.

By writing the above CSS rule, all first-level headings on the page will be red (if no rule overrides it).

Go to CodeWorlds