FSM Full Stack Masterclass
Platform under construction
CSS course badge

Typography & Visual Style

Intermediate

Backgrounds

Backgrounds create surfaces, depth and visual context. They can be simple colors, images, gradients or layered effects.

.hero {
  background: linear-gradient(rgba(7,17,31,.8), rgba(7,17,31,.8)), #07111f;
}

Typography & Visual Style

Backgrounds support content. They should not fight it.

The background property can control color, images, gradients, repeat behavior, position and size.

A background is often part of the reading environment. If it is too busy, low contrast or poorly cropped, the content suffers.

Professional CSS treats backgrounds as layers: base color, surface treatment, image, overlay and foreground readability.

background-color

The safest base layer for a surface.

background-image

Can use images, gradients or multiple layers.

background-size

cover fills the box; contain keeps the full image visible.

background-position

Controls which part of an image remains visible.

Visual model

Make visual decisions systematic instead of random.

Typography and visual style are where CSS starts to feel like design. These models turn subjective choices into reusable decisions you can explain, test and improve.

Base

A stable color behind everything.

Image

The visual layer that carries mood or subject.

Overlay

A contrast layer that protects text.

Content

The foreground that must remain readable.

Examples

High-end visual CSS has a reason behind every value.

Layered readable background

.hero {
  background:
    linear-gradient(rgba(7, 17, 31, .76), rgba(7, 17, 31, .76)),
    url("/assets/images/lesson.jpg") center / cover;
}

Image fighting text

.hero {
  background-image: url("/assets/images/busy-photo.jpg");
  color: white;
}

Rules that matter

Visual style becomes professional when it becomes repeatable.

A beautiful one-off style is not enough. The goal is a visual system that keeps working when the site grows, content changes and new pages are added.

Start with a color

A background color protects the design while images load or fail.

Protect text contrast

Use overlays when text sits on images.

Choose cover or contain deliberately

cover crops; contain may leave empty space.

Position the subject

background-position decides what stays visible.

Avoid noisy surfaces

A busy background can make even good typography fail.

Test responsive crops

Images crop differently on mobile and desktop.

Production thinking

Visual polish must survive real content, real users and real devices.

Why does this matter?

Backgrounds establish atmosphere and surface hierarchy, but content must remain the boss.

Accessibility

Text over images needs strong contrast. Do not rely on a background image to communicate essential information.

Production note

Optimize background images and define fallback colors. Large decorative images can slow the page.

SEO note

Important images should usually be real img elements with alt text, not only CSS backgrounds.

Live code lab

Change the CSS and watch the interface respond.

The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.

Mini assignment

Try this now.

  • Remove the dark gradient and judge text contrast.
  • Swap the radial-gradient position from 75% 25% to 10% 80%.
  • Add background-color as the final fallback layer.

Practice assignment

Do this before moving to the next lesson.

  1. Create a hero with at least two background layers.
  2. Add readable text on top.
  3. Explain which layer protects contrast.

Try it yourself

Build a readable hero background

Live preview

Self-check

Before you continue, prove that you understand Backgrounds.

Intermediate

Answer these questions before moving on. If your answer is vague, change the lab values and judge the visual result again.

  1. Can you explain multiple background layers?
  2. Can you choose cover and contain deliberately?
  3. Can you protect text contrast over a visual background?
  4. Can you provide a fallback background color?
  5. Can you decide when an image should be HTML instead of CSS background?

Senior audit upgrade

Background images need performance and contrast control.

Large background images can be heavy, and text over imagery needs a real contrast strategy.

Image weight

Compress and size backgrounds for the largest real display need, not the original camera file.

Overlay

Use overlays or surface layers when text sits on complex imagery.

Fallback color

Set a readable background color for slow image loading.