Chapter 1 of 12
CSS โ Cascading Style Sheets โ is the language that controls how HTML looks. Without it, every website would be plain black text on a white background. CSS is what makes the web visually distinct.
ANALOGY
HTML is the skeleton, CSS is everything else. If HTML is the bones of a building โ walls, floors, windows โ CSS is the paint, the furniture, the lighting, and the landscaping. The structure stays the same; CSS changes how it all looks and feels.
CSS is made of rules. Each rule targets one or more HTML elements (the selector) and defines a list of declarations โ property/value pairs that change how those elements look.
/* Selector Declaration block */
h1 {
color: #EDE8DC; /* property: value */
font-size: 2.5rem;
font-weight: 700;
}<!-- 1. Inline โ directly on the element. Avoid for anything but quick tests -->
<p style="color: red; font-size: 18px;">Red text</p>
<!-- 2. Internal โ in a <style> tag in the <head>. OK for small single pages -->
<head>
<style>
p { color: blue; }
</style>
</head>
<!-- 3. External โ a separate .css file linked in the <head>. Always use this -->
<head>
<link rel="stylesheet" href="style.css" />
</head>TIP
Always use external stylesheets. Keeping CSS in a separate file means you can style multiple HTML pages from one place. Change the file once, update every page. This is how every real website works.