HTML Element Style How to - Center div with auto margin


We would like to know how to center div with auto margin.


<!DOCTYPE html>
<style type='text/css'>
.center {<!--from   ww w  . j av  a2 s  . co  m-->
  margin: 0 auto;
  width: 300px;
  height: 100px;
  background-color: #000
    <div class="center"></div>

The code above is rendered as follows: