CSS Introduction
Understand the role of CSS and connect a stylesheet to a meaningful HTML document.
CSS is a rule language for presentation. A selector chooses elements, a property names a visual decision, and a value supplies that decision. Keeping structure in HTML and presentation in CSS makes both layers easier to reason about.
See the core pattern
Read this rule set from the outside in. Identify the inputs, the decision or transformation, and the result before changing it.
/* styles.css */
body {
margin: 0;
color: #10231f;
background: #f8f6ef;
font-family: system-ui, sans-serif;
}
h1 {
max-width: 14ch;
line-height: 1;
}Working rules
- Link one stylesheet from the document head
- Start with readable defaults before component styles
- Use browser developer tools to inspect applied rules
A common mistake
Do not use CSS to replace missing HTML meaning. A styled div is still a div; choose the correct element first.
Guided practice
Change the background and heading width, then explain which layer owns each decision.
- Copy the example into the editable notebook below.
- Change one thing at a time and keep the program or rule valid.
- Explain the result in one sentence without relying on jargon.
Lesson review
You should now be able to recognize the css introduction pattern, explain why it is useful, and apply it in a focused example. Complete the checks below before moving to the next lesson.