There are three ways to add CSS to HTML.
| Type | Where | Best for |
|---|
| Inline | style attribute on one element | Quick tests, one-off change |
| Internal | <style> tag in the head | One page only |
| External | Separate .css file linked with <link> | Whole websites. Best choice |
<!-- inline -->
<p style="color:red;">Text</p>
<!-- internal -->
<style>
p { color: red; }
</style>
<!-- external -->
<link rel="stylesheet" href="style.css">
External CSS is the best for real sites, because one file styles all the pages and the browser keeps it in the cache. See HTML Styles.
Learn more about the similar topics:
| Tutorials |
| No Content Found. |
| Exercises & Assignments |
| No Content Found. |
| Interview Questions & Answers |
| No Content Found. |