Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Add The Styles using the Class Name | Introduction to CSS
CSS Fundamentals

book
Challenge: Add The Styles using the Class Name

Task

The website provides brief information about the planets. The task is:

  • Select all elements with the text class name and apply the color property with the value brown.

  • Select all elements with the sub-text class name and apply the color property with the value grey.

html

index.html

css

index.css

copy
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<section>
<h2 class="heading">Jupiter</h2>
<img
src="https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/css-fundamentals/introduction+to+css/jupiter+challenge.png"
alt="Jupiter"
width="32px"
/>
<p class="sub-text">Was formed 4.5 billion years ago</p>
<p class="text">
Jupiter, the fifth planet from the Sun, is the largest planet in our
solar system. It has a massive red spot and over 70 known moons.
</p>
</section>
<section>
<h2 class="heading">Saturn</h2>
<img
src="https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/css-fundamentals/introduction+to+css/saturn+challenge.png"
alt="Saturn"
width="32px"
/>
<p class="sub-text">Was formed 4 billion years ago</p>
<p class="text">
Saturn, the sixth planet from the Sun, is known for its iconic rings
made of ice and rock. It has over 80 moons and a unique hexagonal storm.
</p>
</section>
</body>
</html>

Use . and its class name (e.g., .text) to select an element by its class name.

html

index.html

css

index.css

copy
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<section>
<h2 class="heading">Jupiter</h2>
<img
src="https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/css-fundamentals/introduction+to+css/jupiter+challenge.png"
alt="Jupiter"
width="32px"
/>
<p class="sub-text">Was formed 4.5 billion years ago</p>
<p class="text">
Jupiter, the fifth planet from the Sun, is the largest planet in our
solar system. It has a massive red spot and over 70 known moons.
</p>
</section>
<section>
<h2 class="heading">Saturn</h2>
<img
src="https://codefinity-content-media.s3.eu-west-1.amazonaws.com/code-1/css-fundamentals/introduction+to+css/saturn+challenge.png"
alt="Saturn"
width="32px"
/>
<p class="sub-text">Was formed 4 billion years ago</p>
<p class="text">
Saturn, the sixth planet from the Sun, is known for its iconic rings
made of ice and rock. It has over 80 moons and a unique hexagonal storm.
</p>
</section>
</body>
</html>

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5

Fragen Sie AI

expand
ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

some-alt