CSS / How CSS Rules Style a Page

Learn it, then run it

This lesson includes a working CSS compiler. Your lesson stays here while you practise.

Your learning progress

Checking your account...

Watch this lesson

How CSS Rules Style a Page

Load this RayTech lesson through YouTube. Playback uses YouTube's player and privacy policies.

RayTech Institute · YouTube lessonOpen on YouTube

In this lesson

Understand the idea

Predict before you run


What will happen?
Understand the idea

See how it works

CSS exampleRead the code, then try a change.







See how it works

CSS exampleRead the code, then try a change.





See how it works

CSS exampleRead the code, then try a change.






Spot the mistake

Your turn

Show hint
Write separate rules for body, h1, p and button. Change appearance with declarations inside braces, not by typing HTML into the CSS editor.
Show solution
A valid solution can combine the three worked examples. Use different readable colours if desired. Check that the paragraph remains readable in the narrow preview and that the button's text is not hidden by its background.
Understand the idea

Follow the program

  1. 1
  2. 2
  3. 3
  4. 4

Step 1 of 4

This is an authored walkthrough, not a live debugger. Run the code in Practice to verify the result.

Change it and explain it




Loading an example does not run it. Your existing edits are protected by a replacement confirmation.

Understand the idea

Understand the idea

Understand the idea

Understand the idea

Your turn

Understand the idea

AI suggested activity

Build the result yourself. Complete every check in a part to unlock the next part of this same lesson. You can retry freely.

Lessons, practice, tests and Codi voice are open to everyone. Cloud voice requires consent and shares a limited free allowance. Sign-in is required for AI assignment feedback and is optional for saving progress. Guest work clears on reload; signed-in students can restore their last saved checkpoint.

CSS topics