HTML Element Style How to - Make a border to wrap around text








Question

We would like to know how to make a border to wrap around text.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from   w ww .ja v a 2 s. c o  m-->
  background-color: blue;
  width: 100%;
  padding: 10px;
}

span {
  padding: 10px;
  margin: 10px;
  border: 10px solid white;
  color: white;
  display: inline-block;
}
</style>
</head>
<body>
  <div>
    <span>java2s.com</span> <span>this is a test</span> <span>.</span>
  </div>
</body>
</html>

The code above is rendered as follows: