Python 3 Ways to Add CSS to HTML
There are 3 ways to connect CSS to HTML: Inline (inside the style="" attribute), Internal (inside a <style> tag in the <head>), and External (a separate styles.css linked via <link>). In professional production, External stylesheets are king.
"Inline CSS is like putting sticky notes directly on every piece of furniture. Internal CSS is writing a styling guide on the wall in the living room. External CSS is having an official interior design blueprint book that can style 100 different houses simultaneously."
Deep Dive: How It Works
1. Inline CSS: <p style="color: red;">Hello</p>. Quick for testing, but terrible for maintainability—never use in production!
2. Internal CSS: <head><style>p { color: red; }</style></head>. Great for single-page landing pages or email templates.
3. External CSS: <head><link rel="stylesheet" href="styles.css"></head>. The industry gold standard because one CSS file can style 500 pages at once.
Syntax Blueprint
<!-- External (Best Practice) -->
<link rel="stylesheet" href="style.css">
<!-- Internal -->
<style>
h1 { color: #38bdf8; }
</style>Link external stylesheets in the <head> for fast caching and modular design.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Putting <style> tags inside an external .css fileWhy it happens: Thinking .css files require <style> wrappers.
How to fix: .css files contain raw CSS rules only—never put HTML <style> tags inside a .css file.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Create an internal style tag
Write an internal <style> block containing a rule for body setting color: #ffffff;
Finished reading and practicing?
Mark this lesson as completed to update your course progress.