Colors & the Box Model Lesson 7 of 33
CSS Borders and Rounded Corners
Draw borders around elements with CSS — width, style and color — style each side separately, and make rounded corners and circles with border-radius.
A border is a line drawn around an element. Borders separate sections, frame pictures, and outline buttons and form boxes. In CSS, every border has three parts: a width, a style, and a color.
The border shorthand
Most of the time you set all three at once:
border: 2px solid #0f5c4d;
/* width style color */
<style>
.card { border: 2px solid #0f5c4d; padding: 12px; }
</style>
<div class="card">Quiz #3 — Friday, 10:00 AM</div>
Border styles
<style>
p { padding: 8px; border-width: 4px; border-color: #0038A8; font-family: monospace; }
</style>
<p style="border-style: solid;">solid</p>
<p style="border-style: dashed;">dashed</p>
<p style="border-style: dotted;">dotted</p>
<p style="border-style: double;">double</p>
<p style="border-style: groove;">groove</p>
<p style="border-style: ridge;">ridge</p>
<p style="border-style: inset;">inset</p>
<p style="border-style: outset;">outset</p>
In real websites, solid is by far the most used, with dashed sometimes used for "drop your file here" areas or coupons.
One side at a time
Use border-top, border-right, border-bottom and border-left to style only one side. A bottom border under a heading, or a thick left border on a quote, are both very common designs:
<style>
h2 { border-bottom: 3px solid #f2b33d; padding-bottom: 4px; }
.quote {
border-left: 6px solid #0f5c4d;
background: #e3f1ec;
padding: 10px 14px;
font-style: italic;
}
</style>
<h2>Words of Wisdom</h2>
<p class="quote">"Ang hindi lumingon sa pinanggalingan ay hindi makararating sa paroroonan."</p>
You can also set the width, style or color separately, for example border-color: red; or border-top-width: 5px;.
Rounded corners: border-radius
border-radius rounds the corners of an element. It works even without a border. It rounds the background too.
<style>
.b { background: #0f5c4d; color: white; padding: 14px; margin: 8px 0; font-family: monospace; }
</style>
<div class="b" style="border-radius: 0;">border-radius: 0</div>
<div class="b" style="border-radius: 8px;">border-radius: 8px</div>
<div class="b" style="border-radius: 20px;">border-radius: 20px</div>
<div class="b" style="border-radius: 999px;">border-radius: 999px (pill shape)</div>
A huge value like 999px makes a "pill" shape, popular for buttons and tags.
Circles
Give an element the same width and height and border-radius: 50% to make a perfect circle. This is how profile pictures become round:
<style>
.avatar {
width: 120px;
height: 120px;
border-radius: 50%;
border: 4px solid #f2b33d;
object-fit: cover;
}
.dot { width: 40px; height: 40px; border-radius: 50%; background: #CE1126; display: inline-block; }
</style>
<img class="avatar" src="/img/halo-halo.svg" alt="Halo-halo">
<span class="dot"></span>
Different corners
Give four values to round each corner differently, starting from the top-left and going clockwise: top-left, top-right, bottom-right, bottom-left.
border-radius: 20px 20px 0 0; /* only the top corners — nice for card headers */
Outline vs. border
outline looks like a border but doesn't take up space and can't be rounded on older browsers. Browsers use outlines to show which element has keyboard focus, the ring you see when you press Tab. Never remove it with outline: none unless you add another visible focus style, or keyboard users won't know where they are on the page.
Practice: a ticket
<style>
.ticket {
max-width: 320px;
border: 2px dashed #b4372b;
border-radius: 12px;
padding: 16px;
background: #fff8ec;
font-family: Arial, sans-serif;
}
.ticket h3 { margin: 0 0 8px; color: #b4372b; border-bottom: 1px solid #e6c9a8; padding-bottom: 6px; }
.fare { font-size: 28px; font-weight: bold; }
</style>
<div class="ticket">
<h3>🚌 Cubao → Fairview</h3>
<p>Regular fare</p>
<p class="fare">₱25.00</p>
</div>
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04