CSS Layout How to - Indent line with margin








Question

We would like to know how to indent line with margin.

Answer


<!--   w  w w . j  a v a  2 s .co m-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div.line {
  width: 75%;
  height: 1px;
  margin-left: 25%;
  background: red;
}
</style>
</head>
<body>
  <div class="line"></div>
</body>
</html>

The code above is rendered as follows: