Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →To link an external CSS file to an HTML page, add a <link> element inside the page’s <head>, set rel="stylesheet", and point href to the CSS file. Save both files and reload the page in a browser to check the result.
1. Create the HTML and CSS files
Keep the files in one project folder so their locations are easy to check. For example, the folder might contain index.html and styles.css. Add a simple rule to styles.css so you can tell whether the stylesheet is working:
As an Amazon Associate I earn from qualifying purchases.
h1 {
color: red;
}
2. Add the stylesheet link in the HTML head
Place this element between the opening and closing <head> tags in your HTML document:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
rel="stylesheet" tells the browser the linked resource is CSS for this page. The href value gives the stylesheet’s location. Putting the link in <head> is the conventional, recommended organization for document links. MDN’s <link> reference explains the element’s attributes and placement.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
3. Make the href match the folder structure
The path in href must match where the CSS file actually sits relative to the HTML file. These examples assume the HTML document is in the project’s top-level folder:
| CSS file location | href value |
|---|---|
| Beside the HTML file | styles.css |
In a subfolder named styles |
styles/style.css |
In a styles folder one level above the HTML file’s folder |
../styles/style.css |
Paths are interpreted from the HTML document’s location. Check each folder name, filename, and capitalization; a path that does not match the actual files will not load the stylesheet. MDN’s CSS getting-started tutorial shows the basic link and relative-path workflow.
Rank #2
4. Save and check the page
- Save the HTML file after adding the link.
- Save the CSS file after adding the test rule.
- Open the HTML file in a browser, or reload it if it is already open.
- Check whether the heading appears red. A conspicuous test style makes it easier to tell whether the connection works.
A linked stylesheet is fetched by the browser, parsed, and applied to matching elements in the document. See MDN’s explanation of how browsers load websites.
Why use an external stylesheet?
External CSS keeps styling in a separate file that can be linked from multiple HTML pages. Two other methods are available, but they serve different needs:
Rank #3
| Method | Where the CSS goes | Typical scope |
|---|---|---|
| External stylesheet | A separate CSS file linked with <link rel="stylesheet" href="…"> |
Can be reused by multiple pages |
| Internal stylesheet | A <style> block in the HTML document’s head |
That document |
| Inline style | A style attribute on an HTML element |
The element carrying the attribute |
An internal stylesheet can be convenient when keeping styles in a separate file is impractical. External CSS is usually the clearer choice when you want to reuse rules or keep presentation separate from markup. These are distinct ways of applying CSS, not alternate forms of the external link.
What to check if the styles do not appear
- Confirm the link is in the page you opened. Make sure you edited the same HTML file that the browser is displaying.
- Check the path and spelling. Compare the
hrefvalue with the CSS file’s actual folder and filename, including capitalization. - Save both files. Unsaved changes are not available for the browser to load.
- Reload the page. Then check the obvious test rule again.
- Check the selector and HTML. The test rule applies only if the page contains a matching
<h1>element.
Optional link attributes
For an ordinary CSS file, type="text/css" is unnecessary; MDN recommends omitting it. The rel value is important because a <link> element can describe other relationships, such as a site icon. A stylesheet can also use a media condition for a particular context, such as print, but neither attribute is needed for the basic setup. See MDN’s link-element documentation for details.
Quick Recap
Best Value
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




