Page Widget How to - Center left aligned text div








Question

We would like to know how to center left aligned text div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#long {<!--from   w ww .jav  a  2  s . co m-->
  margin: 50px auto;
  text-align: left;
  padding: 0px 100px;
  background: white;
}

.wrap {
  text-align: center;
}

#short {
  margin: 0px; auto;
  text-align: left;
  outline: 1px dotted blue;
  display: inline-block;
}
</style>
</head>
<body>
  <div id="long">long, long,long, long, long, long, long, long,
    long, long, long, long, long, long, long, long, long, long, long,
    long, long, long, long, long, long, long, long, long, long, long,
    long, long,</div>
  <div class="wrap">
    <div id="short">
      short, short, short <br>short, short, short, short, short, short
      <br>short, short
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: