انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Web: home
0. Lab tour1
1. HTML: the page's content7
2. CSS: the page's look6
3. JavaScript: the actions7
4. The project: the to-do list3
5. Pro CSS: shadows and movement5
6. Arrays and building the page with code3
7. Events and forms3
8. Objects and time3
9. Canvas: drawing and games3
10. The final project: the memory game3

CSS colours

Section 2: CSS: the page's lookLesson 2.1 · ⏱ 7 min

In CSS we choose the element, then write its properties between { }: color is the colour of the words, background the background, and font-size the size of the letters. Every line ends with ;.

HTML
<h1>Robo Egypt</h1>
<p>Coding and robotics academy</p>
CSS
body { font-family: Tahoma; text-align: center; }
h1 {
  color: #5B3DF5;
  font-size: 48px;
}
🖥️ The page in Robo Web:The page in Robo Web

📌 Another example: colours and text in the middle

We colour the background and the title, and put the words in the middle.

🌐 Colours and text in the middle
HTML
<h1>Hello!</h1>
<p>This is my colourful page.</p>
CSS
body {
  font-family: Tahoma, sans-serif;
  background: #FFF4C2;
  text-align: center;
}
h1 { color: #E5484D; font-size: 48px; }
p { color: #1B2350; }
🖥️ The page in Robo Web:The page in Robo Web
✍️ Practise
Colour the title.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Make the title green.

👀 Show the solution
🌐 Solution
HTML
<h1>Green</h1>
CSS
h1 { color: green; }
🖥️ The page in Robo Web:The page in Robo Web

Result: a green title.

Medium

The page background is light blue, and every paragraph is size 22px.

👀 Show the solution
🌐 Solution
HTML
<p>Paragraph 1</p>
<p>Paragraph 2</p>
CSS
body { background: lightblue; }
p { font-size: 22px; }
🖥️ The page in Robo Web:The page in Robo Web

Result: a blue background and bigger words.

Hard

Two paragraphs: each has a class and a different colour.

👀 Show the solution
🌐 Solution
HTML
<p class="hot">Summer is hot ☀️</p>
<p class="cold">Winter is cold ❄️</p>
CSS
.hot { color: orangered; }
.cold { color: steelblue; }
🖥️ The page in Robo Web:The page in Robo Web

Result: an orange paragraph and a blue paragraph.

Finished the lesson? Mark it so your progress counts.