Phase 2 — CSS Fundamentals
#7 Colors and typography
color, font, text, Google Fonts
Color formats
CSS supports multiple color formats:
Color values
/* Named colors */
color: red;
background: cornflowerblue;
/* Hexadecimal */
color: #3b82f6; /* 6-digit */
color: #3b82f680; /* with alpha */
color: #38f; /* 3-digit shorthand */
/* RGB / RGBA */
color: rgb(59, 130, 246);
color: rgba(59, 130, 246, 0.5);
/* HSL / HSLA — Hue, Saturation, Lightness */
color: hsl(217, 91%, 60%);
color: hsla(217, 91%, 60%, 0.5);Typography
Font properties
body {
font-family: 'Inter', system-ui, sans-serif;
font-size: 16px;
font-weight: 400; /* 100-900, normal=400, bold=700 */
line-height: 1.6; /* Unitless multiplier recommended */
letter-spacing: 0.02em;
word-spacing: 0.05em;
}Text styling
Text properties
h1 {
text-align: center;
text-transform: uppercase;
text-decoration: underline;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
p {
text-indent: 2em; /* First line indent */
white-space: nowrap; /* Prevent wrapping */
overflow: hidden;
text-overflow: ellipsis; /* Show ... when truncated */
}Using Google Fonts
Google Fonts
<!-- In your HTML <head> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
/* In your CSS */
body {
font-family: 'Inter', sans-serif;
}Your turn
Try the color and typography commands below:
terminal — browser