Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 36 ยท Interaction and Visual Design

Typography and Color for UX

Choose readable type sizes, line lengths and color palettes for interfaces. Build a modular type scale and a color ramp with live, runnable examples.

Most of an interface is text, so typography is not decoration: it is the interface. Color then adds meaning (an error, a success, a link). Both are easy to get subtly wrong and hard to fix late, so it pays to set up a small, consistent system early.

This lesson gives you practical defaults for type and color, building on visual hierarchy and leading into accessible contrast.

Readable type

  • Body size: 16 px is a good minimum for web body text. Smaller text is hard to read on phones and for older users.
  • Line length: aim for 45 to 75 characters per line. Longer lines make the eye lose its place.
  • Line height: 1.4 to 1.6 times the font size for body text; headings can be tighter (1.1 to 1.3).
  • Alignment: left-align paragraphs in left-to-right languages. Centered long text and full justification are harder to read.
  • Fonts: one or two families are enough. A system font stack is fast and familiar; a web font adds personality but costs load time.
  • Weight: use regular for body, medium or semibold for emphasis. Avoid very thin weights for small text.
Line length and line height

A modular type scale

Instead of picking font sizes one by one, pick a base and a ratio, then multiply. A ratio of 1.25 (called a "major third") gives steps that are clearly different but related.

Python Generate a type scale

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Round the results to whole pixels in a real design system. Smaller screens often use a smaller ratio (1.125 to 1.2) so headings do not dominate.

Color with a purpose

A useful interface palette has three layers:

  1. Neutrals: backgrounds, borders, text (white through near-black). They make up most of the screen.
  2. Brand or primary color: the main accent for primary buttons and links.
  3. Semantic colors: red for errors and destructive actions, green for success, amber for warnings, blue for information.

Define each color as a ramp of shades (for example 50, 100, ..., 900) so you can pick lighter tints for backgrounds and darker shades for text.

Python Build a color ramp

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This is a simple linear mix, enough to teach the idea. Production ramps are usually tuned by eye or in a perceptual color space so steps look even.

Color is not the only signal

About 1 in 12 men and 1 in 200 women have some form of color vision deficiency. Never rely on color alone: pair a red error border with an icon and a text message, and underline links inside body text. This also helps in bright sunlight and on grayscale printouts.

A form that only turns a field red on error tells color-blind users nothing. Always add text such as "Enter a valid email address".

Color meaning varies

Red means danger in many cultures but good luck or celebration in others. Keep semantic colors consistent inside your product and test with the audience you serve.

Dark mode basics

Dark themes are not simply inverted colors. Use dark gray (not pure black) backgrounds, slightly desaturate bright accents, and reduce very high contrast white text to an off-white to limit glare.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a good minimum size for body text on the web?

    16 px is the common minimum for comfortable body text, especially on phones.
  2. 2. What is the benefit of a modular type scale?

    A base size and a ratio produce a small set of harmonious sizes instead of arbitrary values.
  3. 3. Why should an error state use more than a red color?

    Color alone fails for color-blind users; add text and an icon.
  4. 4. What is a good line length for body text?

    Moderate lines let the eye return to the next line easily.

Summary

  • Use 16 px body text, 45 to 75 characters per line and generous line height.
  • Build a modular type scale from a base size and a ratio.
  • Organize color into neutrals, a primary accent and semantic colors, each as a ramp.
  • Never use color as the only signal; pair it with text or icons.
  • Treat dark mode as its own design, not an inversion.

Next: Interaction Patterns and Feedback