<!DOCTYPE html> <html> <head> <style> body > span { border: 3px solid blue } body > span > span { border: 3px solid cyan } .notstart { border-left: none; } .notend { border-right: none; } </style> </head> <body> <span class="notend"> <span class="notend"> <span>One</span><span>Two</span><span>Three</span> </span> </span> <div>Four</div> <span class="notstart notend"><span class="notstart notend"></span></span> <div>Five</div> <span class="notstart notend"> <span class="notstart notend"> <span>Six</span> </span> </span> <div>Seven</div> <span class="notstart notend"><span class="notstart notend"></span></span> <div>Eight</div> <span class="notstart"> <span class="notstart"> <span>Nine</span> </span> </span> </body> </html>