Effect How to - Create titled border








Question

We would like to know how to create titled border.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from   w ww. j ava2s  . c  o  m-->
  border: 1px dashed black;
  width: 300px;
  height: 100px;
  margin: 50px;
}

div p {
  margin-top: -0.5em;
  margin-left: 10px;
  background-color: white;
  display: block;
  width: 150px;
}
</style>
</head>
<body>
  <div>
    <p>YOUR TEXT HERE</p>
  </div>
</body>
</html>

The code above is rendered as follows: