How to add a border to an image with CSS?

CSSWeb DevelopmentFront End Technology

Following is the code to add a border to an image using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
img {
   border: 8px solid rgb(0, 238, 255);
   width: 400px;
   height: 400px;
}
</style>
</head>
<body>
<h1>Border Around Image Example</h1>
<img src="https://images.pexels.com/photos/34950/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 08-Apr-2020 11:21:57
Advertisements