CSS Typography

Master Fonts, Text Styling, and Readability

πŸ”€ Interactive Font Family Explorer

Experiment with different font families and see their impact on text:

This is a Heading

This is a Subheading

This is a paragraph of regular text that demonstrates how the selected font family affects readability and overall appearance. Typography is the art and technique of arranging type to make written language legible, readable, and appealing when displayed.

Bold text and italic text show different font weights and styles.

"Typography is the craft of endowing human language with a durable visual form." - Robert Bringhurst

Current Font:

Inter, sans-serif

Sans-serif Modern Readable

πŸŽ›οΈ Typography Properties Playground

Adjust typography properties and see their effects in real-time:

18px
1.6
0px
0px

Typography Example

This text changes as you adjust the typography controls. Watch how different properties affect readability, spacing, and overall appearance. Typography is crucial for creating engaging and accessible web content.

Experiment with different combinations to understand how each property contributes to the overall design and user experience.

Generated CSS:

font-size: 18px;
line-height: 1.6;
letter-spacing: 0px;
word-spacing: 0px;
font-weight: 400;
text-align: left;
text-transform: none;
text-decoration: none;

✨ Text Effects Showcase

Explore various text effects and styling techniques:

Text Shadow

Shadowed Text
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);

Gradient Text

Gradient Text
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;

Outlined Text

Outlined Text
-webkit-text-stroke: 2px #333;

3D Text Effect

3D Text
text-shadow: 1px 1px 0px #ccc, 2px 2px 0px #c9c9c9, 3px 3px 0px #bbb;

Neon Glow

Neon Glow
text-shadow: 0 0 5px #ff6b6b, 0 0 10px #ff6b6b, 0 0 15px #ff6b6b;

Embossed Text

Embossed
text-shadow: 0 1px 0 rgba(255,255,255,0.8);

🌐 Web Fonts Integration

Learn how to integrate and use web fonts:

Google Fonts Implementation

1. HTML Link Method:
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
2. CSS Import Method:
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
3. CSS Usage:
font-family: 'Inter', sans-serif;

Local Font Files

@font-face Declaration:
@font-face {
  font-family: 'MyCustomFont';
  src: url('fonts/mycustomfont.woff2') format('woff2'),
       url('fonts/mycustomfont.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}
CSS Usage:
font-family: 'MyCustomFont', Arial, sans-serif;
Font Format Support:
  • WOFF2 - Best compression, modern browsers
  • WOFF - Good support, older browsers
  • TTF/OTF - Fallback for very old browsers
  • EOT - Internet Explorer support

Font Stack & Fallbacks

Well-structured Font Stack:
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
Common Font Stacks:
Sans-serif: font-family: Arial, Helvetica, sans-serif;
Serif: font-family: Georgia, "Times New Roman", serif;
Monospace: font-family: "Courier New", Courier, monospace;

πŸ“ Typography Best Practices

Learn industry standards for readable and accessible typography:

πŸ“– Readability Guidelines

Line Length: 45-75 characters per line
This line demonstrates optimal reading length for comfortable scanning and comprehension.
Line Height: 1.4 - 1.6 times font size

This text has tight line spacing (1.0) which can feel cramped.

This text has optimal line spacing (1.6) for comfortable reading.

This text has loose line spacing (2.0) which may feel disconnected.

🎨 Visual Hierarchy

Main Heading (H1)

Section Heading (H2)

Subsection (H3)

Body text provides the main content and should be sized for comfortable reading across devices.

Secondary text like captions or metadata can be smaller and less prominent.

β™Ώ Accessibility Considerations

  • Contrast Ratio: Minimum 4.5:1 for normal text
  • Font Size: Minimum 16px for body text
  • Font Weight: Avoid very light weights (<400)
  • ALL CAPS: Use sparingly, harder to read
  • Color Alone: Don't rely solely on color for meaning
βœ“ Good contrast (7.2:1)
βœ— Poor contrast (2.1:1)

πŸ“± Responsive Typography

/* Fluid typography */
font-size: clamp(1rem, 2.5vw, 1.5rem);

/* Responsive line height */
line-height: 1.4;

/* Scale headings */
h1 { font-size: clamp(1.75rem, 4vw, 3rem); }

πŸ’ͺ Typography Challenge

Design a typographically pleasing article layout:

Customize the Article:

16px
1.6

The Art of Typography in Web Design

Typography is more than just choosing fontsβ€”it's about creating a visual hierarchy that guides readers through your content effortlessly.

Understanding Visual Hierarchy

Visual hierarchy helps readers understand the relative importance of different elements on a page. Through careful use of font sizes, weights, and spacing, designers can create a clear path for the reader's eye.

"Typography is the craft of endowing human language with a durable visual form, and thus with an independent existence." β€” Robert Bringhurst

Key Principles

  • Maintain consistent spacing and alignment
  • Use contrast to emphasize important information
  • Choose fonts that complement your content
  • Ensure readability across all devices

By applying these principles thoughtfully, you can create typography that not only looks beautiful but also enhances the user experience and communicates your message effectively.

Typography Score:

85/100

πŸ“š Typography Reference

Font Properties

  • font-family - Font typeface
  • font-size - Size of text
  • font-weight - Thickness (100-900)
  • font-style - Normal, italic, oblique
  • line-height - Space between lines

Text Properties

  • text-align - Horizontal alignment
  • text-decoration - Underline, strikethrough
  • text-transform - Uppercase, lowercase
  • letter-spacing - Space between characters
  • word-spacing - Space between words

Web Font Best Practices

  • Load fonts asynchronously when possible
  • Use font-display: swap for better performance
  • Preload critical fonts
  • Always include fallback fonts
  • Limit the number of font variants

Typography Scale

  • H1: 2.5rem (40px)
  • H2: 2rem (32px)
  • H3: 1.5rem (24px)
  • H4: 1.25rem (20px)
  • Body: 1rem (16px)
  • Small: 0.875rem (14px)