CSS Property Value How to - before: content and style








Question

We would like to know how to before: content and style.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#test_div:before {<!--from  w  w  w .j a  va 2s . co m-->
  position: absolute;
  width: 100%;
  padding: 10px;
  top: 0;
  content: '';
  left: 2px;
  background: red;
  height: 1px;
}

#test_div {
  border: 1px solid #E3E3E3;
  border-top: 0;
  width: 300px;
  height: 250px;
  position: relative;
}
</style>
</head>
<body>
  <div id="test_div"></div>
</body>
</html>

The code above is rendered as follows: