Recommended Free Tools
To add CSS to an HTML page, put a style attribute on one element, add a <style> block in the page’s <head>, or link a separate .css file with <link rel="stylesheet">. For styles you want to reuse across pages, an external stylesheet is usually the best default: one file can control the appearance of multiple HTML documents, as MDN explains in its CSS getting-started guide.
Choose where the CSS should live
| Method | Where the CSS goes | Best fit | Main tradeoff |
|---|---|---|---|
| Inline | An element’s style attribute |
A single element or a quick demonstration | The declaration is attached to markup and is harder to reuse consistently. |
| Internal | A <style> element in an HTML document |
A small, single-page example or page-specific CSS | The rules stay in that HTML file rather than a shared stylesheet. |
| External | A separate CSS file connected by a <link> element |
Styles reused across pages | The link’s href must point to the file’s actual location. |
MDN documents all three approaches and recommends external stylesheets as the most common and useful method, particularly when the same styles are needed on multiple pages. See its overview of adding CSS.
As an Amazon Associate I earn from qualifying purchases.
How to add CSS to one element with inline styles
Place CSS declarations inside the element’s style attribute. The value uses normal CSS declaration syntax, including a colon between the property and value and a semicolon after the declaration:
Windows 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 reinstallOutdated 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 match<p style="color: rebeccapurple;">This paragraph is purple.</p>
Inline CSS is useful when a style applies to just that element. Because the presentation is mixed into the HTML, repeating or changing styles across many elements can become awkward to maintain.
#1 Best Overall
How to add CSS to one HTML document with an internal stylesheet
Put rules inside a <style> element, conventionally in the document’s <head>. The selector identifies which elements the rule affects:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example</title>
<style>
p {
color: rebeccapurple;
}
</style>
</head>
<body>
<p>This paragraph is purple.</p>
</body>
</html>
The <style> element contains styling information for a document or part of one. Internal CSS keeps page-specific rules with the HTML file, which is convenient for a self-contained example but does not provide a shared stylesheet for other pages. MDN describes the element in its reference for <style>.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
How to link an external CSS file to HTML
1. Create the stylesheet
Save a file named styles.css alongside the HTML file. Put CSS rules in the file without HTML tags:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
p {
color: rebeccapurple;
}
2. Link it from the document head
Add a <link> element inside the HTML document’s <head>:
<link rel="stylesheet" href="styles.css">
The rel="stylesheet" value identifies the linked resource as a stylesheet, and href gives its location. The path must match where the file is saved: if it is in a folder named css, use href="css/styles.css". MDN explains the element and its stylesheet relationship in the reference for <link>.
Rank #3
An external file is a practical default when styles should be shared among pages. Each page can link to the same CSS file, so a rule need not be copied into every HTML document.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Where to put CSS when a page uses more than one method
A page can contain inline declarations, a <style> block, and one or more linked stylesheets. Their effects are resolved by the CSS cascade; simply placing a rule in one location does not mean it universally wins.
Rank #4
For normal author declarations, an inline style takes precedence over normal author stylesheet declarations. But the cascade evaluates origin and importance before specificity, and layer order, scoping proximity, and source order can also affect the result. Important declarations, user or browser styles, animations, and transitions add further exceptions. Specificity is compared only at the appropriate stage and within the same origin and layer. MDN describes the purpose of the process: “The cascading algorithm determines how to find the value to apply for each property for each document element.” Read its introduction to the CSS cascade and specificity guide for the full rules.
When styles unexpectedly differ, first check that the external file’s href resolves to the file you edited. Then inspect the competing declarations and their importance, origin, layer, specificity, and order rather than assuming that inline CSS always wins.
Quick Recap
Best Value
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.




