Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Welcome to Chapter 5! 🔤
Have you ever noticed how different websites feel completely unique just by their lettering? A government circular uses serious, formal lettering, a tech startup uses clean, geometric letters, and a coding platform uses typewriter-style text.
In CSS, typography is controlled primarily through the font-family property.
In this lesson, you will learn:
Imagine you are looking at different students' notebooks in your classroom:
How data and code flow step-by-step
Look closely at the capital letter "T" in both styles:
Times New Roman, Georgia) feel traditional, literary, and authoritative. They are widely used in newspapers, novels, and legal documents.Arial, Helvetica, Trebuchet MS) feel modern, friendly, and clean. Because they are easier to read on low-resolution computer screens and smartphone displays, most modern websites choose Sans-Serif as their primary font!When a student visits your website, their browser can only display a font if that font is already installed on their computer or mobile phone.
If you use a rare, fancy font that only exists on your computer, the student's browser won't have it and will default to an ugly fallback font!
Web-Safe Fonts are fonts that come pre-installed on virtually every Windows, Mac, Android, iPhone, and Linux device in the world:
| Generic Family | Popular Web-Safe Fonts |
|---|---|
| Sans-Serif | Arial, Helvetica, Verdana, Trebuchet MS, Tahoma |
| Serif | Times New Roman, Georgia, Garamond |
| Monospace | Courier New, Consolas, Lucida Console |
In CSS, you never declare just a single font name. Instead, you provide a comma-separated list called a Font Stack:
sans-serif font is installed on the device!"'Times New Roman' or 'Segoe UI'), you must wrap it in quotes! Single words (like Arial or sans-serif) do not need quotes.What if you want a super sleek, award-winning font like Poppins, Roboto, or Inter that might not be pre-installed on older devices?
You can use Google Fonts for free! Google hosts the font files on its servers and delivers them to the user's browser automatically.
<head>Now, every student in the world will see your website in gorgeous, modern Poppins lettering, whether they are on an old phone or a brand-new laptop!
| What Beginners Do (Don't ❌) | What You Should Do Instead (Do ✅) | Why? |
|---|---|---|
font-family: Times New Roman; (No quotes) | font-family: 'Times New Roman', serif; | Multi-word font names must be wrapped in quotes. |
Listing only one font: font-family: 'Poppins'; | Always end with a generic fallback: font-family: 'Poppins', sans-serif;. | If the internet connection fails, the browser knows to pick a matching generic style. |
| Using 10 different decorative fonts on one page. | Stick to 1 or 2 cohesive fonts (one for headings, one for body text). | Too many fonts look chaotic and slow down page loading. |
font-family property sets the typeface of an element.sans-serif or serif).'Courier New').Test your understanding with these multiple-choice questions:
sans-serif at the very end of a font stack?typography.html.In the next lesson, we will continue your web styling journey with Font Size, Weight, Style, and Line Height (Text and Fonts).
👉 Continue to Next Lesson: Font Size, Weight, Style, and Line Height →
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| The Box-Sizing Property: border-box vs content-box | Font Size, Weight, Style, and Line Height |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.