CSS Basics Handout
CSS Basics Handout
1. Introduction to CSS
CSS (Cascading Style Sheets) controls the presentation of HTML documents.
Key Features:
Copy
Download
Run
<h1 style="color: blue; font-size: 24px;">Hello!</h1>
Copy
Download
Run
<head>
<style>
h1 {
color: blue;
font-size: 24px;
}
</style>
</head>
Copy
Download
Run
<head>
<link rel="stylesheet" href="styles.css">
</head>
📁 styles.css
css
Copy
Download
h1 {
color: blue;
font-size: 24px;
}
3. CSS Selectors
Selector Example Description
Copy
Download
body {
font-family: Arial, sans-serif;
font-size: 16px;
color: #333;
text-align: center;
line-height: 1.5;
}
Copy
Download
h1 {
color: white;
background-color: #1e90ff;
background-image: url("bg.jpg");
}
Copy
Download
.container {
display: flex;
justify-content: center; /* Horizontal alignment */
align-items: center; /* Vertical alignment */
gap: 20px; /* Space between items */
}
.item {
flex: 1; /* Expands to fill space */
}
6. CSS Grid (Advanced Layouts)
Grid allows 2D layouts (rows & columns).
css
Copy
Download
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr; /* 3 equal columns */
grid-gap: 10px;
}
.item {
grid-column: span 2; /* Takes 2 columns */
}
Copy
Download
/* Default styles */
body {
font-size: 16px;
}
9. Next Steps
Learn CSS animations & transitions
Explore CSS frameworks (Bootstrap, Tailwind)
Practice by: