Boostrap: Add Border to Image in 3 Easy Steps

Ruth Jul 09, 2026

Adding a border to an image can significantly enhance its visual appeal and make it stand out. In Bootstrap, a popular CSS framework, this can be achieved with just a few lines of code. Let's delve into how you can add a border to an image using Bootstrap.

How to add a border to a photo with Photoshop
How to add a border to a photo with Photoshop

Before we proceed, ensure that you have included the Bootstrap CSS library in your HTML file. If you haven't, you can add it using the following line in the section of your HTML:

an ornate blue and white frame with flowers on the border, in front of a white background
an ornate blue and white frame with flowers on the border, in front of a white background

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">

Now, let's explore how to add a border to an image in Bootstrap.

Adding a Border Using Bootstrap Classes

How To Add A Border In Photoshop - Lenscraft
How To Add A Border In Photoshop - Lenscraft

Bootstrap provides several pre-defined classes that can be used to add borders to images. These classes are based on the border-width, border-style, and border-color properties in CSS.

Here are some of the classes you can use:

How to Add Borders to Photos: 11 Easy Methods
How to Add Borders to Photos: 11 Easy Methods
  • border - Adds a default border.
  • border-1, border-2, border-3, border-4, border-5 - Adds a border with the specified width.
  • border-primary, border-secondary, border-success, border-danger, border-warning, border-info, border-light, border-dark - Adds a border with the specified color.
  • border-start, border-end, border-top, border-bottom - Adds a border to the specified side.

Using Border Class

The border class adds a default border to an image. Here's how you can use it:

How to Create a Border in Photoshop Elements
How to Create a Border in Photoshop Elements

<img src="image.jpg" class="border">

This will add a 1px solid border in the default color (black) around the image.

Using Border Width Classes

To add a border with a specific width, you can use the border- classes. For example, to add a 2px border:

W3Schools.com
W3Schools.com

<img src="image.jpg" class="border-2">

You can also combine these classes with color classes to customize the border further:

<img src="image.jpg" class="border-2 border-primary">

Customizing Borders with Custom CSS

a square frame with a black border around it
a square frame with a black border around it
6 ways to add borders with PaintShop Pro | Scrapbook Campus
6 ways to add borders with PaintShop Pro | Scrapbook Campus
an empty square with no image or text to describe on the bottom right corner, it is white and has a black border
an empty square with no image or text to describe on the bottom right corner, it is white and has a black border
a pink and white checkered table cloth with a lace border in the center on a black background
a pink and white checkered table cloth with a lace border in the center on a black background
How to put border for your photos in photoshop - Padhuskitchen
How to put border for your photos in photoshop - Padhuskitchen
.
.
a blue and white frame with rope border
a blue and white frame with rope border
a green and white frame with an ornate border
a green and white frame with an ornate border
a white square with some black spots on it's edges and an area for text to be added
a white square with some black spots on it's edges and an area for text to be added
black and white stars on a white background
black and white stars on a white background
How to Add a Border to a Photo in Photoshop | Quick Tips!
How to Add a Border to a Photo in Photoshop | Quick Tips!
an ornate border with flowers and leaves on a black background stock photo - 1387982
an ornate border with flowers and leaves on a black background stock photo - 1387982
How to Add Borders to Photos: 11 Easy Methods
How to Add Borders to Photos: 11 Easy Methods
Borders For Paper, Borders And Frames, Box Design, - Golden Frame Design Png, Transparent Png(1275x841) - PngFind
Borders For Paper, Borders And Frames, Box Design, - Golden Frame Design Png, Transparent Png(1275x841) - PngFind
Decorative Border Frame With Intricate Corners On A  Transparent PNG. Png - Free PNG Images ID 33754 | TopPNG
Decorative Border Frame With Intricate Corners On A Transparent PNG. Png - Free PNG Images ID 33754 | TopPNG
a black and white drawing of a square frame
a black and white drawing of a square frame
Diseño De Borde PNG ,dibujos  Diagrama Vectorial, De Sombreado, Marco PNG y PSD para Descargar Gratis | Pngtree
Diseño De Borde PNG ,dibujos Diagrama Vectorial, De Sombreado, Marco PNG y PSD para Descargar Gratis | Pngtree
A4 Size Color Page Border Eps Vector Design, Color Page Border Design, Page Border Design Eps, Frame PNG and Vector with Transparent Background for Free Download
A4 Size Color Page Border Eps Vector Design, Color Page Border Design, Page Border Design Eps, Frame PNG and Vector with Transparent Background for Free Download
How to Add Borders to Photos: 11 Easy Methods
How to Add Borders to Photos: 11 Easy Methods
an ornate gold and black border with flowers on the side, in front of a white background
an ornate gold and black border with flowers on the side, in front of a white background

While Bootstrap provides many options for adding borders, you might need to customize the border further to match your specific design needs. In such cases, you can use custom CSS to override the Bootstrap styles.

Here's how you can add a custom border using inline styles:

<img src="image.jpg" style="border: 3px dashed #ff0000;">

In this example, a 3px dashed red border is added to the image.

Using an ID or Class for Custom CSS

For more complex customizations, it's better to use an ID or class for the image and define the styles in your CSS file or a