HTML Element Style How to - Turn div to inline block








Question

We would like to know how to turn div to inline block.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!-- w w  w  . j  a  v  a  2 s  . c  o  m-->
  text-align: center;
}

#spry {
  background-color: red;
  display: inline-block;
}
</style>
</head>
<body>
  <div id="spry">
    <p>hello there</p>
  </div>
</body>
</html>

The code above is rendered as follows: