CSS Property Value How to - Add gap between outline and border of a div








Question

We would like to know how to add gap between outline and border of a div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from w  ww .jav  a 2s . co  m-->
  width: 200px;
  height: 200px;
  background: #ccc;
  border: 5px solid red;
  outline: 3px solid green;
  outline-offset: 5px;
}
</style>
</head>
<body>
  <div></div>
</body>
</html>

The code above is rendered as follows: