Borders, Radius, and Shadows

← All TutorialsCSS · Lesson 8 of 20

Borders define edges, border-radius rounds corners, and box-shadow adds depth. Use subtle shadows rather than heavy effects for a clean interface.

What you will learn

  • Explain the purpose of borders, radius, and shadows in a real website.
  • Read and adapt a working example instead of memorizing syntax.
  • Test your result and recognize a common implementation mistake.

Understanding the concept

Use subtle shadows for depth and keep focus outlines visible for keyboard users.

CSS rules select elements and assign property–value pairs. The cascade, specificity, and source order determine which declaration wins.

This topic is part of the CSS learning track. Read the example carefully, identify each important element or statement, and try changing one part at a time. Small experiments help you see cause and effect.

Example 1: Working code

.card { border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 8px 24px rgb(15 23 42 / 8%); }

Create an HTML file containing <div class="practice">Example</div>. Add the stylesheet inside a <style> element or external CSS file.

How to understand this example

  1. Identify the syntax introduced by this lesson.
  2. Read the code from top to bottom and predict what it will do.
  3. Run the code, then compare the result with your prediction.
  4. Change one value, selector, or element and run it again.

Example 2: A small experiment

/* Experiment: Borders, Radius, and Shadows */
.practice-8 {
  padding: 1rem;
  border: 2px solid #2563eb;
  border-radius: 0.75rem;
}

This second example is a practice scaffold. It is not a replacement for the main example; combine the ideas to make a small working page or script.

Common mistakes and best practices

  • Use responsive units and test layouts on narrow screens.
  • Inspect computed styles in Developer Tools when a rule seems ignored.
  • Do not copy examples without understanding the result; inspect and test them.
  • Prefer clear, descriptive names and simple code over unnecessary complexity.

Hands-on exercise

Your task: Style a course card with a soft border and shadow.

Extra challenge: Improve the example for a real DevLearn student portfolio or small business website. Explain your changes in two sentences.

Show exercise guidance

Apply the example rule to a test element, change the relevant property, and compare its appearance at desktop and mobile widths.

Quick knowledge check

  1. What problem does borders, radius, and shadows solve?
  2. Which part of the main code example would you modify first?
  3. How would you test that your change works?
Suggested answers

Use subtle shadows for depth and keep focus outlines visible for keyboard users. The relevant part depends on your change; test by running the code and inspecting the result using the browser and its developer tools.

Next steps

Complete the exercise without copying the solution. Save your code in a folder named css-lesson-08, then continue to the next lesson in this track.

Want live, instructor-led practice?

Explore DevLearn courses for guided projects and feedback.

Explore Live Courses →
Questions about a course?☎ Call Now