Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape

CSS Borders

CSS Borders

CSS CODES & EXAMPLES

CSS Borders

Learn how to create, style and customize borders around HTML elements. Explore border styles, width, color, radius, individual sides, outlines and practical website designs.

01

What are CSS Borders?

Create visible boundaries around HTML elements

CSS borders are used to create a visible line around an element. Borders can be customized using different styles, colors, widths and corner radii.

Important Properties: border border-style border-width border-color border-radius outline
02

Basic Border

Create a simple border

The simplest way to create a border is to use the border shorthand property.

basic-border.css
.box {
  border: 2px solid #1769d5;
}
Basic Border
03

Border Style

Choose different border patterns

The border-style property defines the style of the border.

border-style.css
.solid {
  border: 3px solid #1769d5;
}

.dashed {
  border: 3px dashed #1769d5;
}

.dotted {
  border: 3px dotted #1769d5;
}

.double {
  border: 5px double #1769d5;
}
solid Continuous line
dashed Dashed line
dotted Dotted line
double Double line
04

Border Width

Control the thickness of a border

border-width.css
.thin {
  border: 1px solid #1769d5;
}

.medium {
  border: 3px solid #1769d5;
}

.thick {
  border: 6px solid #1769d5;
}
1px
3px
6px
05

Border Color

Change the color of your border

border-color.css
.box {
  border-style: solid;
  border-width: 3px;
  border-color: #1769d5;
}
Blue
Green
Orange
Purple
07

Border Radius

Create rounded corners

The border-radius property rounds the corners of an element.

border-radius.css
.card {
  border: 2px solid #1769d5;
  border-radius: 20px;
}

.circle {
  border-radius: 50%;
}
0px
10px
25px
50%
08

Individual Corner Radius

Round specific corners

corner-radius.css
.box {
  border-radius:
    30px
    10px
    30px
    10px;
}
Custom Rounded Corners 30px • 10px • 30px • 10px
09

CSS Outline

Create an external line around an element

An outline is similar to a border but it does not take up space in the normal box layout.

outline.css
.box {
  border: 2px solid #1769d5;
  outline: 3px dashed #f59e0b;
  outline-offset: 6px;
}
Border + Outline
10

Border Shorthand

Combine width, style and color

border-shorthand.css
.box {
  border: 3px solid #1769d5;
}
3px + solid + #1769d5

The shorthand combines three values: border-width, border-style and border-color.

11

Border Hover Effect

Create interactive cards using CSS

border-hover.css
.card {
  border: 2px solid #e2e8f0;
  transition: .3s;
}

.card:hover {
  border-color: #1769d5;
  transform: translateY(-5px);
}
HOVER ME

Interactive Card

Move your mouse over this card to see the border hover effect.

13

Professional Card Border

Practical website design example

card-border.css
.card {
  padding: 25px;

  background: white;

  border:
    1px solid
    #e4eaf1;

  border-radius: 16px;

  transition: .3s;
}

.card:hover {
  border-color: #1769d5;

  box-shadow:
    0 12px 30px
    rgba(23,105,213,.12);
}
FEATURED COURSE

Certificate in Computer Application

Professional computer education with practical learning and career-focused skills.

View Course →
14

Image Border

Create attractive image containers

image-border.css
img {
  width: 220px;
  height: 220px;

  object-fit: cover;

  border:
    5px solid
    #1769d5;

  border-radius: 50%;

  padding: 5px;
}
SNCEC
15

CSS Borders Live Preview

Run a complete border example

LIVE PREVIEW
16

CSS Borders Quick Reference

Important properties at a glance

PropertyExamplePurpose
borderborder: 2px solid blue;Shorthand border
border-widthborder-width: 3px;Controls thickness
border-styleborder-style: dashed;Controls border pattern
border-colorborder-color: blue;Controls border color
border-radiusborder-radius: 15px;Rounds corners
outlineoutline: 2px solid red;Creates external outline
outline-offsetoutline-offset: 5px;Creates space around outline
17

Practice Task

Build a professional course card

🎯 Practice: Create a Course Card

Create a professional course card using the border properties learned in this lesson.

  • Add a 1px solid border.
  • Use a light gray border color.
  • Add 16px border radius.
  • Create a hover border-color effect.
  • Add a subtle box shadow on hover.
  • Create a rounded course image.
  • Add a bordered “Enroll Now” button.
`;document.getElementById( "sncecBorderPreview" ).srcdoc = code;}document.addEventListener( "DOMContentLoaded", function(){sncecBorderRun();} );

HTML Paragraph

  • 17/08/2026

HTML Lists

  • 17/08/2026

CSS Colors

  • 17/08/2026

Leave a Reply

Your email address will not be published. Required fields are marked *