Computer >> Computer tutorials >  >> Programming >> CSS

How to add a border to an image with CSS?


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

Example

<!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 −

How to add a border to an image with CSS?