Introduction to CSS & Inclusion Methods
If HTML is the skeleton of a website, CSS is the skin, clothes, personality, and visual presentation.
What is it?
CSS stands for Cascading Style Sheets. It is a stylesheet language used to describe the presentation and layout of a document written in HTML.
Why is it used?
Without CSS, websites look like black-and-white 1990s word processor documents. CSS controls colors, fonts, spacing, responsive multi-column layouts, and fluid animations across screen sizes.
Detailed Explanation
Syntax Structure
/* CSS Rule Syntax */
selector {
property: value;
}
Code Example
<!-- External linking preferred -->
<link rel="stylesheet" href="/static/css/style.css">
<!-- Internal CSS Example -->
<style>
body {
background-color: #f7f4ed;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: #1c1c1c;
margin: 0;
padding: 24px;
}
h1 {
color: #1c1c1c;
font-size: 28px;
letter-spacing: -0.5px;
}
</style>
Explanation of the Code
Expected Output
Real-World Application
Production web applications use external CSS stylesheets bundled and minified by Vite, Webpack, or Tailwind to load instantly on client devices.
Common Mistakes to Avoid
Quick Practice Challenge
Create an external file `styles.css`, link it to your HTML document, and give the page body a light background and custom font.