The <fieldset> element is usually thought of as a form-grouping container, and its <legend> child as the caption for that group. Together they ship with a behavior that is hard to reproduce by hand: the group gets a border, the caption sits directly in that border, and the border line stops at the caption and picks up again after it. That "text in border" look is built in, so we can reuse it for a modern border-text design that is quick to write and easy to change.

The markup

One border per box means four <fieldset> elements, each holding a <legend>. The text that should appear along each edge goes inside the matching <legend>.

<fieldset><legend>Wash Your Hands</legend></fieldset>
<fieldset><legend>Stay Apart</legend></fieldset>
<fieldset><legend>Wear A Mask</legend></fieldset>
<fieldset><legend>Stay Home</legend></fieldset>

Stacking and borders

Place all four fieldsets in the same grid cell so they overlap. A grid is convenient but not required. Set borders on them, making only the top border of each box visible and the other three transparent — the <legend> text renders at the top border by default, so that is the edge we want to keep. Give every fieldset box-sizing: border-box so width and height include border and padding; this is what lets the legend styling produce edges that line up.

body {
  display: grid; 
  margin: auto; /* to center */
  margin-top: calc(50vh - 170px); /* to center */
  width: 300px; height: 300px; 
}

fieldset {
  border: 10px solid transparent; 
  border-top-color: black; 
  box-sizing: border-box; 
  grid-area: 1 / 1; /* first row, first column */
  padding: 20px; 
  width: inherit; 
}

Then rotate the last three fieldsets so that their top borders serve as the right, bottom and left edges of the design.

/* rotate to right */
fieldset:nth-of-type(2){ transform: rotate(90deg); }
/* rotate to bottom */
fieldset:nth-of-type(3){ transform: rotate(180deg); }
/* rotate to left */
fieldset:nth-of-type(4){ transform: rotate(-90deg); }

Legend styling

The legend is where the border-text effect is won or lost. Give it a line-height of zero, or something small enough. A large line height pushes the border it sits in downward; since the border shifts with the line height, the four sides stop joining up and the borders have to be repositioned. Font size, line height and family can be set together through the font shorthand.

legend {
  font: 15pt/0 'Averia Serif Libre'; 
  margin: auto; /* to center */
  padding: 0 4px; 
}

fieldset:nth-of-type(3) > legend { 
  transform: rotate(180deg);
}

The legend of the third fieldset, fieldset:nth-of-type(3)>legend, renders upside-down because its parent is rotated, so flip it vertically to restore the normal text direction. The first fieldset can then hold an image to complete the layout.

Positioning the text along the edge

Lateral margins slide the legend text along its border. Left and right margins both set to auto center the text. Setting only the left margin to auto pushes the text to the right edge; only the right margin to auto pushes it to the left.

The same technique extends beyond rectangles — the fieldsets can be arranged into other angles, such as an octagon.