HTML Element Style How to - Set text width in round div








Question

We would like to know how to set text width in round div.

Answer


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

body {
  font: 10px sans-serif;
}

p {
  background: red;
  text-align: center;
  border-radius: 50px;
  width: 100px;
  height: 100px;
}

p span {
  vertical-align: middle;
  display: inline-block;
}

p span:first-child {
  height: 100px;
}
</style>
</head>
<body>
  <p>
    <span></span><span>This is some text which will wrap if it gets
      too long!</span>
  </p>
</body>
</html>

The code above is rendered as follows: