1 of 31

Colors and Typography

Ketan Mayer-Patel

UNC Department of Computer Science

COMP 426: Modern Web Programming (Fall 2026)

Module 5: Design

Lecture 20

2 of 31

Colors

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Colors make up a large part of our UI designs.
    • They also can separate a good design from a great design.
    • Keeping to a specific color theme promotes the design principle of consistency.
    • Can help define your app or company’s brand identity.
      • Amazon
      • Duolingo
      • Netflix

3 of 31

Anatomy of a Color

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Hue: Determines the color family.
    • Red? Orange? Yellow? etc…

​

  • Saturation: Intensity of the color.
    • From greyer to richest color.�
  • Brightness: Amount of darkness applied.
    • From darker to brighter.

4 of 31

Anatomy of a Color

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Hue: Determines the color family.
    • Red? Orange? Yellow? etc…

​

  • Saturation: Intensity of the color.
    • From greyer to richest color.�
  • Brightness: Amount of darkness applied.
    • From darker to brighter.

Hue

5 of 31

Anatomy of a Color

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Hue: Determines the color family.
    • Red? Orange? Yellow? etc…

​

  • Saturation: Intensity of the color.
    • From greyer to richest color.�
  • Brightness: Amount of darkness applied.
    • From darker to brighter.

Saturation

6 of 31

Anatomy of a Color

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Hue: Determines the color family.
    • Red? Orange? Yellow? etc…

​

  • Saturation: Intensity of the color.
    • From greyer to richest color.�
  • Brightness: Amount of darkness applied.
    • From darker to brighter.

Brightness

7 of 31

Color Representations

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • There are many ways to represent colors.�
  • RGB: Quantifies amount of red, green, and blue in a color.

rgb(160,120,140) Values range from 0-255

  • HEX: Quantifies amount of red, green, and blue in a color as hexadecimals.

#3F89CC Values range from 0-FF (0-255 in hexadecimal)

  • HSL: Quantifies hue, saturation, and brightness of a color.

hsl(160,100% ,50%) Hue values range from 0-360 (degree on color wheel)� Saturation + brightness values range from 0-100%.

8 of 31

Another Value: Alpha

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • We can add an alpha value to represent opacity of the color.
  • RGBA: Quantifies amount of red, green, and blue in a color + alpha.

rgba(160,120,140,0.5) Alpha value ranges from 0-100%.

  • HEX: We can add two more digits to represent the alpha.

#3F89CC3C Alpha value ranges from 0-FF.

  • HSL: Quantifies hue, saturation, and brightness of a color.

hsl(160,100%,50%,0.5) Alpha value ranges from 0.0-1.0.

9 of 31

Creating a Color Palette

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • Typically, a color palette for UI design consists of five parts:
    • Background Color: This color is used for most of your site’s background.
    • Text Color: This color is used for most of your site’s plain text.
    • Primary Color: Main branding color for your site that is used throughout.
    • Secondary Color: Color paired with the primary color with less prominence.
    • Accent Color: Color that “pops” against the primary color for more prominence.
  • When designing a website, you want to select a set of colors that you want to base your design on.
    • This set of colors is called a color palette.�

10 of 31

Creating a Color Palette

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • What do I mean by prominence?
    • We want to “point out” certain UI elements to users.
    • Some elements should appear more “emphasized” to the user than others.
    • For example, consider these buttons:

M5: Design

L20

Save Changes

Cancel

Creates a hierarchy of importance / “weight” of action.

The “Save Changes” button performs a mutating action, the “Cancel” button does not.

Look! These animated pop ups have different prominence levels...

11 of 31

60-30-10 Rule

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • The 60-30-10 rule determines the rough appearance of colors on a page.
    • 60% of colored items should be the “dominant” (primary) color.
    • 30% of items should be colored with the “complement” (secondary) color.
    • 10% of items should be colored with the “accent” color.
  • Inspired by interior design!

Primary

Accent

Secondary

12 of 31

Generating a Color Palette

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

M5: Design

L20

  • There are a few tools that make generating color palettes easy:
    • Realtime Colors: Shows all five classes of colors and an example site.
    • Coolors: Popular site for generating color palettes.

13 of 31

Pitfalls!

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • There are a few constraints that help to guide selecting colors.�
  • Your background color and text color should have sufficient contrast.
    • Otherwise, you could end up with something like this!

Or something like this…

    • You can check contrast between two colors with a tool like this:
      • Coolors Color Contrast Checker
    • Sufficient contrast is essential (especially for those with visual impairment)

​

M5: Design

L20

14 of 31

Pitfalls!

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • There are a few constraints that help to guide selecting colors.�
  • Color choices should pair well together and not be too jarring.
    • Typically, colors with high saturations should be avoided.
      • Instead, opt for colors with a lower saturation value!
    • Contrast also plays a role.
      • Blue and red together have very high contrast and look bad together…

… especially on top of each other! X _ x

​

M5: Design

L20

15 of 31

Pitfalls!

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • There are a few constraints that help to guide selecting colors.�
  • Background and text colors are often neutral.
    • This means they are very close to white/gray/black.

​

M5: Design

L20

16 of 31

Dark Mode

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • Consider dark mode as well!
    • This often flips around colors across the palette.
    • You often want two contrasting palettes for light mode and dark mode.

M5: Design

L20

17 of 31

Dark Mode

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

  • Consider dark mode as well!
    • This often flips around colors across the palette.
    • You often want two contrasting palettes for light mode and dark mode.

M5: Design

L20

18 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Typography

M5: Design

L20

  • Typography: Art / technique of designing fonts and typefaces.
    • In addition to colors, typography has a large effect on the presentation, style,

and branding of your site!

​

  • Font: Specific style for text.
    • These fonts can be grouped into categories.

19 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Aa

Monospaced

Aa

Display

20 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Aa

Monospaced

Aa

Display

​

Serif��Typeface that includes serifs (the small decorator lines) at the extremities of the letters.

Oftentimes, the width of each stroke in the letter may not be uniform.

21 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Aa

Monospaced

Aa

Display

San Serif��Typeface that excludes serifs.

The width of each stroke in the letter is often uniform.

Used as the standard font type for many websites!

22 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Aa

Monospaced

Aa

Display

Handwritten��Typeface that looks like it was handwritten or written in calligraphy.

This is not commonly used for text on websites, but is commonly used in logos (when giving a personal touch is appreciated!)

23 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Monospaced

Aa

Display

Monospaced��Typeface where every character shares the same width.

Often looks like a typewriter font.

Often used to represent code.

This is how I have used it for slides!

<p>Hello, world!</p>� � vs <p>Hello, world!</p>

Aa

24 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Types of Fonts

M5: Design

L20

Aa

Serif

Aa

San Serif

Aa

Handwritten

Aa

Monospaced

Aa

Display

Display��Typeface that is fancy and striking, drawing the user’s attention.

This is not commonly used for body on websites, but is may be used for titles or high-prominence headers (<h1>!)

25 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Typography

M5: Design

L20

  • Let’s explore some fonts!

​

  • Google Fonts ( ): Incredible resource for finding and loading in external fonts.
    • Link
    • Also INCREDIBLE resource material for learning about typography.

26 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Anatomy of a Font

M5: Design

L20

27 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Line Spacing, Character Spacing, and Kerning

M5: Design

L20

28 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Another Cool Feature: Drop Cap

M5: Design

L20

You often see this on news articles, web novels, etc!

29 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Choosing Type

M5: Design

L20

  • How should I combine types?
    • Resource

30 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

100

200

300

400

500

600

700

800

900

We usually just think of normal and bold - but there are many more options!

Important: Font Weights

M5: Design

L20

  • Font weights are very important for defining structure and hierarchy to text.
    • Emphasized items appear “thicker” than others - this is font weight!
      • De-emphasized items appear thinner, which helps our eyes to prioritize what content to read.
    • Font weights range from 100 (thin) to 900 (black).�

Thin Extra Light Light Normal Medium Semibold Bold Extra Bold Black

31 of 31

COMP 426: Modern Web Programming (Fall '26)

Colors and Typography

Applying Typography

M5: Design

L20

  • We have been using Tailwind for styling our React components.
    • We can apply all of the typography parameters we have talked about - fonts, font styles, font weight, line spacing, character spacing, etc!
    • Tailwind Typography Docs