Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Practice Structural Pseudo-Classes | The CSS Box Model & Spacing Elements
CSS Fundamentals
course content

Kursusindhold

CSS Fundamentals

CSS Fundamentals

1. Getting Started with CSS
2. Styling Text in CSS
3. The CSS Box Model & Spacing Elements
4. Mastering Flexbox for Layouts
5. Adding Decorative Effects with CSS

book
Challenge: Practice Structural Pseudo-Classes

Task

We are working with a set of elements, and the goal is to practice applying different colors using structural pseudo-classes. Your task is as follows:

  • Apply the color red to the first element using a structural pseudo-class.

  • Apply the color blue to the last element using a structural pseudo-class.

  • Apply the color green to every second element using a structural pseudo-class.

html

index.html

css

index.css

copy
  • :first-child: Targets the first child of a parent element.

  • :last-child: Targets the last child of a parent element.

  • :nth-child(): Targets a specific child of a parent element based on its position in the list. For instance, to select every second list item (2, 4, 6, etc.), you can use :nth-child(2n).

html

index.html

css

index.css

copy

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

CSS Fundamentals

CSS Fundamentals

1. Getting Started with CSS
2. Styling Text in CSS
3. The CSS Box Model & Spacing Elements
4. Mastering Flexbox for Layouts
5. Adding Decorative Effects with CSS

book
Challenge: Practice Structural Pseudo-Classes

Task

We are working with a set of elements, and the goal is to practice applying different colors using structural pseudo-classes. Your task is as follows:

  • Apply the color red to the first element using a structural pseudo-class.

  • Apply the color blue to the last element using a structural pseudo-class.

  • Apply the color green to every second element using a structural pseudo-class.

html

index.html

css

index.css

copy
  • :first-child: Targets the first child of a parent element.

  • :last-child: Targets the last child of a parent element.

  • :nth-child(): Targets a specific child of a parent element based on its position in the list. For instance, to select every second list item (2, 4, 6, etc.), you can use :nth-child(2n).

html

index.html

css

index.css

copy

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6
Vi beklager, at noget gik galt. Hvad skete der?
some-alt