-1
HTML 4 and 5 Voce can use <legend>:
<form>
 <fieldset>
  <legend>Exemplo:</legend>
    <input type="radio" id="A" name="rdo">
    <label for="A">A</label><br/>
    <input type="radio" id="B" name="rdo">
    <label for="B">B</label><br/>
 </fieldset>
</form>
otherwise Voce can use in this way:
.fieldset-border {
  border: 1px groove #ddd !important;
  padding: 0 1.4em 1.4em 1.4em !important;
  margin: 0 0 1.5em 0 !important;
  -webkit-box-shadow: 0px 0px 0px 0px #000;
  box-shadow: 0px 0px 0px 0px #000;
}
.fieldset-border .legend-border {
  font-size: 1.2em !important;
  text-align: left !important;
  width: auto;
  padding: 0 10px;
  border-bottom: none;
}
<fieldset class="fieldset-border">
  <legend class="legend-border">Teste</legend>
</fieldset>

I think this link solves your question https://answall.com/questions/213100/coloca-texto-na-borda-div
– Renato Neri Júnior
was worth my cheated
– Gabriel