Objective: Add visual style to your HTML pages using Cascading Style Sheets (CSS).
CSS controls how HTML elements look on the page.
<p style="color: blue;">Hello StreetGeek!</p>💡 The style attribute changes appearance without altering content.
| Type | Where it lives | Best for |
|---|---|---|
| Inline | Inside HTML tags with style="" | Quick single use |
| Internal | Inside <style> in the <head> | Small pages |
| External | Separate .css file via <link> | Professional sites |
<link rel="stylesheet" href="styles.css">selector {
property: value;
}p {
color: #333;
font-size: 16px;
}/* Tag selector */
p { color: blue; }
/* Class selector */
.intro { color: green; }
/* ID selector */
#main-title { color: red; }Order of power → Inline > ID > Class > Tag.
| Category | Examples |
|---|---|
| Text | color, font-family, font-size, line-height, text-align |
| Box | margin, padding, border, width, height |
| Background | background-color, background-image, background-size |
| Display | display: block / inline / flex / grid |
red
#FF0000
rgb(255, 0, 0)
hsl(0, 100%, 50%)px, em, rem, %, vh, vwstyles.css.<head>:<link rel="stylesheet" href="styles.css">body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
h1 {
color: #0E477B;
text-align: center;
}
p {
color: #333;
line-height: 1.5;
}Refresh the browser and watch your page transform.
/* Header styles */
header, nav, footer {
background: #0E477B;
color: white;
padding: 20px;
}✅ Use commas to style multiple elements at once.
Style your previous “Resume” or “Profile” page:
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
/* then */
body { font-family: 'Roboto', sans-serif; }line-height control?Next up: 👉 MODULE 6: The CSS Box Model — master margins, borders, and layout spacing.