How to add a border to an image using CSS

Learn how to place a border around an image using CSS in this quick and easy tutorial.

First, create a CSS class that specifies a border:

.img-border {
	border: 6px solid #663399;
}

Next, apply the newly-created class to the desired image:

<img class="img-border" src="/path/to/image.jpg" width="280px" height="180px" alt="This image has a border around it">

That’s all there is to it! You should now see a border around your image.


Love our articles? HostM offers professional and helpful web hosting services with unlimited features and renewal rates that actually match our advertised rates.