CSS styles an HTML document. Keep the HTML and stylesheet in one project folder so you can understand how relative file paths work.
What you need
- A browser and a code editor
- A folder containing index.html and styles.css
Set up your environment
- Create an HTML file that contains
<link rel="stylesheet" href="styles.css">inside its head. Add a heading in the body. - Create
styles.cssin the same folder and add the rules below. - Open
index.htmlin the browser. Save both files after edits. - Inspect the heading in Developer Tools and find the CSS rule that sets its colour.
Your first check
Save as styles.css
body { font-family: Arial, sans-serif; background: #f4f4f4; }
h1 { color: #047857; }Run or verify
Open index.html, then refresh after saving styles.css.Expected result: The heading becomes green and the page background becomes light gray.
Common setup problems
- If the styles do not appear, check the link filename and folder location.
- Check the browser Network panel for a missing stylesheet; use a hard refresh if an old stylesheet is cached.
Official documentation
Guide reviewed 17 November 2026. Check the linked vendor documentation for current supported versions and operating systems.