Lesson 3: From Plain Text to Stunning Design
Transform your HTML into visual masterpieces
This is my very first webpage!
It works, but it looks pretty boring...
A basic linkFunctional? ✅ Beautiful? ❌
Cascading Style Sheets
CSS is the "makeup artist" for your HTML!
HTML = Structure | CSS = Appearance
Content & Structure
Presentation & Design
This makes websites easier to maintain and update!
CSS uses rules to style HTML elements:
h1 { color: blue; font-size: 24px; text-align: center; }
h1 - What element to stylecolor - What aspect to changeblue - How to change itcolor: blue; - Complete instruction<head> <style> h1 { color: red; } </style> </head>
<h1 style="color: red;">Hello</h1>
<link rel="stylesheet" href="style.css">
Open your HTML file from last lesson and add this to the <head> section:
<head> <title>My First Page</title> <style> h1 { color: blue; text-align: center; } </style> </head>
Save and refresh your browser to see the magic happen! ✨
Same content, completely different look! 🎉
p { color: green; /* Text color */ font-size: 18px; /* Text size */ font-family: Arial; /* Font type */ background-color: yellow; /* Background */ padding: 10px; /* Inner spacing */ margin: 20px; /* Outer spacing */ border: 2px solid black; /* Border */ }
CSS gives you many ways to specify colors:
h1 { color: red; } /* Color names */ h2 { color: #ff0000; } /* Hex codes */ p { color: rgb(255, 0, 0); } /* RGB values */
💡 Use online color pickers to find perfect colors!
body { font-family: 'Arial', sans-serif; font-size: 16px; line-height: 1.5; } h1 { font-size: 32px; font-weight: bold; text-decoration: underline; }
Add this CSS to your <style> section:
body { font-family: Arial, sans-serif; background-color: #f0f8ff; padding: 20px; } h1 { color: #2c3e50; text-align: center; border-bottom: 3px solid #3498db; } p { color: #34495e; font-size: 18px; line-height: 1.6; }
Let's organize like real developers:
<link rel="stylesheet" href="style.css">
Now you have clean, organized code! 🎉
Your webpage now looks professional! 🌟
Next: Adding interactivity with JavaScript! 🚀