Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 1.59 KB

README.md

File metadata and controls

53 lines (35 loc) · 1.59 KB

17. CSS syntax and connection

Apply styles with readable rules.

Learn

  • external stylesheet
  • selectors
  • declarations
  • properties
  • comments
  • CSS parsing

Build

Connect styles.css to a page and style text, links, and a section.

Check your work

  • Open the result in a browser and inspect the HTML and computed CSS.
  • Test at narrow and wide widths and use the keyboard for interactive elements.
  • Write down one thing you changed after testing.

Deep lesson

How it works

CSS is a list of rules. Each rule selects elements and declares property/value pairs. A linked stylesheet keeps style separate from document meaning and can serve multiple pages. When the browser cannot understand one declaration, it ignores that declaration and continues, so a typo may fail silently. Comments explain intent but do not replace clear names.

Common mistake

An invalid property or missing stylesheet path can make styling disappear without an obvious page error. Inspect the Styles and Network panels before guessing.

Guided challenge

Write three rules from scratch: one type selector, one class selector, and one hover state. Deliberately misspell a property, inspect the result, then repair it.

Completion check

  • Rebuild the core idea without copying the example line by line.
  • Explain the key HTML or CSS choice in your own words.
  • Test the result at a narrow width and with keyboard navigation where relevant.

Run the example

Open example.html in a browser. Edit style.css, save, and refresh.

Try: Change the notice background and add a border property.