Illustration for 🎨 CSS Basics: Giving Web Pages a Make‑over

CSS Basics: Giving Web Pages a Make‑over

Introduction

Have you ever wondered how a plain web page becomes colorful, organized, and easy to read? The secret sauce is CSS, which stands for Cascading Style Sheets. Think of CSS as the clothing and accessories that dress up the plain HTML “body” of a website. In this guide you’ll learn the building blocks of CSS, see real‑world examples, and even try a tiny experiment yourself!


1. What Is a “style” and Why Does It “cascade”?

  • Style – the way something looks (color, size, shape).
  • Cascade – a fancy word meaning “to flow down”. In CSS, rules that are written later can Override earlier ones, just like water flowing over rocks.

Cause & Effect:
If you set a paragraph’s text color to blue, the words become blue. Later, if you write another rule that says the same paragraph should be red, the red rule cascades over the blue one, so the text finally appears red.

Example:

p {
  /* first rule */
  color: blue;
}
p {
  /* second rule, later in the file */
  color: red; /* this wins! */
}

2. The Three Main Parts of a CSS Rule

A CSS rule looks like a tiny recipe:

selector { property: value; }
PartWhat It DoesKid‑Friendly Explanation
SelectorChooses the HTML element to style (e.g., h1, .button, #logo).“Who are we dressing up?”
PropertyThe characteristic you want to change (e.g., color, font-size).“What part of the outfit?”
ValueThe exact setting (e.g., red, 24px).“How we set it?”

Did You Know? The word Pixel (px) comes from the tiny “picture element” that makes up your screen. One pixel is the smallest dot you can see on a monitor.


3. Adding Color, Size, and Space

A. Colors

Use names (red, green) or Hex Codes like #FF5733. A hex code is a six‑digit secret code for colors.

h1 {
  color: #ff5733; /* bright orange‑red */
}

B. Font Size

font-size decides how tall the letters are. The unit px (pixel) is common, but you can also use em (relative to the surrounding text).

p {
  font-size: 18px; /* big enough to read */
}

C. Spacing (margin & Padding)

  • Margin – space outside an element, like the gap between two boxes.
  • Padding – space inside an element, like the cushion between text and its border.
.card {
  margin: 20px;   /* space around the card */
  padding: 15px;  /* space inside the card */
}

4. Mini Experiment: Style a Button

What You Need:

  • A text editor (like Notepad or VS Code)
  • A web browser

Steps:

  1. Create a file called mypage.html with this code:
<button class="cool-btn">Click Me!</button>
  1. Add a <style> tag in the <head> and write:
.cool-btn {
  background-color: #10b981;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 18px;
}
  1. Open the file in your browser and see your styled button!

Challenge: Try changing the colors and padding to make the button your own.


Quick Quiz

QuestionAnswer
What does CSS stand for?Cascading Style Sheets
What are the three parts of a CSS rule?Selector, Property, Value
What is the difference between margin and padding?Margin is outside space; padding is inside space
What does “cascade” mean in CSS?Later rules can override earlier ones

Now you have the power to dress up any web page. Keep experimenting, and soon you’ll be a CSS stylist!

Continue the adventure

Download Surprise Button for iPad

A simple, safe way for kids to explore the internet. With one tap, they discover something new — a fun fact, a science experiment, a story, or a place in the world they never would've searched for.

Download on the App Store

Your child explores safely on Surprise Button App

🌋

How Volcanoes Form

From Magma to Mountain

Volcanoes grow where tectonic plates collide or drift apart. Heat melts rock into light, buoyant magma that rises, cools, and hardens near the surface, building the cone layer by layer.

Know exactly what to talk about tonight

Maya's Daily Discoveries - March 15 Inbox

🚀 Today's Learning Journey

🌋
How Volcanoes Form
18 min • Longest session today
🎨
Ancient Egyptian Art
15 min • Visited twice today

💬 Tonight's Conversation Starters

"Can you explain how volcanoes form?"