There are many ways to create a block of content with an image border around it. The easiest way is to make a background image and set it to the specific width and height you need, but this way the dimensions are set. To allow it to expand with the the text vertically, specifying the width of a background image and having 2 elements sharing the image for the top and bottom would also be a viable solution. The problem I came across was when I need to make multiple boxes with the same image border but with each having a different width and height. I needed the boxes to be scalable, have the least amount of images as possible, and for the code to be valid. The solution is explained below.

Step 1
Firstly, the markup. To make the box scalable in all directions, I’d have to use a div for each side of the box. These divs would be nested in a wrapper which determined the width. After the markup, we’re going to use CSS to add a background and position to each div in order to create a seamless border.
<div class="border-box">
<div class="top-left">
<div class="top-right">
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="bottom-left">
<div class="bottom-right"></div>
</div>
</div>
Read more…