Connecting a CSS Stylesheet
CSS controls presentation while HTML provides structure.
Connect the file
Create css/style.css, then add this inside the page’s <head>:
<link rel="stylesheet" href="css/style.css">
A relative path is interpreted from the current page. A PHP page in a subfolder may need a different path.
Test the connection
body {
font-family: Arial, sans-serif;
color: #1f2933;
background: #f7f9fc;
}
Refresh without cache if an old version remains.
Good practice
Keep reusable rules in external stylesheets. Avoid large blocks of inline CSS and do not use colour as the only way to communicate meaning.
Check
- Link is inside
head. - Path matches folder structure.
- Browser developer tools show no 404.
- Page remains understandable if CSS does not load.