link rel="stylesheet"
Connects an external CSS file to the HTML document.
Learn External CSS as the bridge between clean HTML and professional CSS: visual hierarchy, maintainable styling, responsive behavior and live practice.
HTML styling foundation
External CSS lives in a separate .css file and is linked from the HTML document. This is the normal production pattern for websites and applications.
The biggest win is reuse. One stylesheet can style many pages, and one class can become part of a design system. The browser can also cache CSS files, which helps performance.
Once a CSS file grows, organization matters. A stylesheet of 2,000 lines can still be fine when it is structured. A random stylesheet of 500 lines can already be painful.
Connects an external CSS file to the HTML document.
Points to the stylesheet location, often assets/css/styles.css.
Browsers can reuse the same CSS file across pages.
Large CSS needs sections, naming rules and eventually splitting.
Syntax and structure
Use rel="stylesheet" and a correct href path. The browser loads the CSS before styling the visible page.
<head>
<link rel="stylesheet" href="/assets/css/styles.css">
</head>
<body>
<article class="course-card course-card--featured">
<h1>External CSS</h1>
<p>One stylesheet can support many pages.</p>
</article>
</body>
<!-- Every page repeats its own styles -->
<style>
.course-card { padding: 32px; }
.button { background: red; }
.hero { min-height: 80vh; }
</style>
Rules that matter
Styling is not only making something look nice once. Good CSS stays readable, reusable and predictable while the project grows.
Shared components should not be restyled from scratch on every page.
Know whether href starts from the current folder, the site root or a parent directory.
Base styles, layout, components and utilities are easier to scan than random order.
A class should explain role or component, not only current color or position.
A huge stylesheet can be split into base, layout, components and pages when the project grows.
HTML should show structure and classes. CSS should carry the visual system.
Production thinking
This matters because CSS becomes serious when the site grows. External CSS is where styling changes from one-page decoration into a maintainable frontend system.
External CSS should include global focus styles, readable line-height, sufficient contrast and responsive behavior shared across the site.
External stylesheets are essential for caching, maintainability, code review and design consistency. They also make it possible to refactor a full site without touching every HTML file.
A clean external stylesheet helps performance and maintainability. Faster, readable pages tend to perform better for users, and user behavior can support search performance indirectly.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.