HTML Element Style How to - Center div horizontally and vertically


We would like to know how to center div horizontally and vertically.


<!DOCTYPE html>
<style type='text/css'>
.wraptocenter {<!--from   w  w  w  . ja v a2s .  c om-->
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  width: 200px;
  height: 200px;
  background-color: #999;

.wraptocenter * {
  vertical-align: middle;

.wraptocenter {
  display: block;

.wraptocenter span {
  display: inline-block;
  height: 100%;
  width: 1px;
  <div class="wraptocenter">
    <span></span><img src=""

The code above is rendered as follows: