CSS (Cascading Style Sheets) controls the visual presentation of HTML. It makes your webpages look great.
What CSS Does
CSS handles:
- Colors and typography
- Layout and positioning
- Spacing and sizing
- Animations and transitions
- Responsive design
Three Ways to Add CSS
<!-- 1. Inline CSS -->
<p style="color: blue; font-size: 18px;">Blue text</p>
<!-- 2. Internal CSS (in <head>) -->
<style>
p { color: blue; font-size: 18px; }
</style>
<!-- 3. External CSS (best practice) -->
<link rel="stylesheet" href="style.css" />
Your First CSS File
/* style.css */
body {
font-family: Arial, sans-serif;
background-color: #f8fafc;
color: #1e293b;
margin: 0;
padding: 0;
}
h1 {
color: #1d4ed8;
font-size: 2rem;
}
p {
line-height: 1.6;
font-size: 1rem;
}
Hong Kong Example
Style a simple student card:
.student-card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
max-width: 320px;
}
.student-card h2 {
color: #1d4ed8;
margin-bottom: 8px;
}
Introduction to CSS
CSS (Cascading Style Sheets) controls the visual presentation of HTML. It makes your webpages look great.
What CSS Does
CSS handles:
- Colors and typography
- Layout and positioning
- Spacing and sizing
- Animations and transitions
- Responsive design
Three Ways to Add CSS
<!-- 1. Inline CSS -->
<p style="color: blue; font-size: 18px;">Blue text</p>
<!-- 2. Internal CSS (in <head>) -->
<style>
p { color: blue; font-size: 18px; }
</style>
<!-- 3. External CSS (best practice) -->
<link rel="stylesheet" href="style.css" />
Your First CSS File
/* style.css */
body {
font-family: Arial, sans-serif;
background-color: #f8fafc;
color: #1e293b;
margin: 0;
padding: 0;
}
h1 {
color: #1d4ed8;
font-size: 2rem;
}
p {
line-height: 1.6;
font-size: 1rem;
}
Hong Kong Example
Style a simple student card:
.student-card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
max-width: 320px;
}
.student-card h2 {
color: #1d4ed8;
margin-bottom: 8px;
}