Give a page its first styles
Connect CSS to a page and write your first selector and declaration.
- Explain what CSS controls
- Recognize a CSS rule
- Connect an external stylesheet
CSS (Cascading Style Sheets) controls how HTML content looks and is arranged. A CSS rule has a selector, which chooses elements, and a declaration block, which sets properties and values. Keep page structure in HTML and visual presentation in CSS.
1h1 {
2 color: darkgreen;
3 font-size: 2rem;
4}h1 text is dark green and larger
An HTML page can load an external stylesheet with <link rel="stylesheet" href="styles.css"> inside its head. The selector h1 matches every h1 element. Inside the braces, each declaration ends with a semicolon.
Key takeaways
CSS controls presentation; HTML describes content.
Selectors choose elements.
Declarations pair a property with a value.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write CSS
Style the sample page, see your changes in the sandboxed preview, and run checks against the computed styles.
Style the headline
Select .page-title and set its text color to #165b33 and font size to 32px.
- Headline styles
Your CSS is applied to a sample page in a sandboxed preview. Tests check computed styles.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…