1fieldset {
2 display: block;
3 margin: 20px auto;
4 padding: 15px;
5 border: 0;
6 border: 1px solid red;
7 width: 50%;
8}
9legend {
10 display: table;
11 min-width: 0px;
12 max-width: 70%;
13 position: relative;
14 margin: auto;
15 padding: 5px 20px;
16 font-size: 20px;
17 text-align: center;
18}
19<fieldset>
20 <legend>legend</legend>
21 <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae obcaecati dolore eligendi quaerat ad et possimus provident amet magni maiores, corporis, cupiditate omnis maxime dolorum saepe adipisci tempora perferendis optio.</div>
22</fieldset>