Kursinnhold
CSS Fundamentals
CSS Fundamentals
1. Getting Started with CSS
What is CSS and Why is it Important?Linking CSS to an HTML DocumentMastering CSS Selectors for Styling HTML ElementsChallenge: Apply Your First CSS StylesChallenge: Style with Class SelectorsEnhancing Styles with User Action Pseudo-ClassesChallenge: Apply User Action Pseudo-ClassesChanging Text Colors in CSSOptimizing Workflow for Efficient CSS CodingChallenge: Use Variables for Better CSS Management
3. The CSS Box Model & Spacing Elements
What is the CSS Box Model?Understanding Box Sizing in CSSAdding Space with Margins and PaddingChallenge: Apply Box Sizing to ElementsUsing Structural and Functional Pseudo-ClassesChallenge: Practice Structural Pseudo-ClassesUnderstanding Block, Inline, and Inline-Block ElementsWorking with Block-Level ElementsWorking with Inline ElementsChallenge: Predict Page Layout with Different Element Types
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.
index.html
index.css
: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)
.
index.html
index.css
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 6