Borders and Shadows
๐ Covered in this chapter:
Border Width ยท Style ยท Color ยท Border Radius ยท Rounded Cards ยท box-shadow ยท Multiple Shadows ยท Inset ยท Outline ยท Focus Outline ยท outline-offset ยท Visual Hierarchy
Welcome to Chapter 15: Borders and Shadows โ part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Border Properties
.card {
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 24px;
background: #fff;
}
.badge {
border-width: 2px;
border-style: dashed;
border-color: #3b82f6;
border-radius: 999px;
}
Shorthand: border: width style color; โ Individual sides: border-top, border-left, etc.
2box-shadow โ Depth & Visual Hierarchy
CSS
.card {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.card:hover {
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.inset-panel {
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}
.elevated {
box-shadow:
0 1px 3px rgba(0,0,0,0.12),
0 8px 24px rgba(0,0,0,0.08);
}
Syntax: box-shadow: x y blur spread color; โ Multiple shadows comma-separated.
3Outline & Focus States (Accessibility)
CSS
button:focus-visible {
outline: 3px solid #93c5fd;
outline-offset: 2px;
}
/* Never remove focus without replacement */
button:focus {
outline: none; /* โ Bad if no alternative */
}
Outline vs border: Outline layout affect cheyadu โ focus rings ki ideal. Keyboard users ki visible focus mandatory.