To achieve the desired styling as Harry suggested, enclose your elements in a wrapper and apply the styling to the wrapper. Here's an example:
div {
font-family: consolas;
border: 2px solid #73AD21;
border-radius: 25px;
}
<div>
<h1>Hello</h1>
<p>World</p>
</div>
If you prefer not to change your markup, another option is to adjust the borders and border-radius for individual elements. For the h1
element, remove the bottom left and right borders and radius. Likewise, for the p
element, remove the top left and right borders and radius. This will give you the desired look.
h1, p {
font-family: consolas;
border: 2px solid #73AD21;
border-radius: 25px;
margin: 0;
padding: 10px 0;
}
h1 {
border-bottom: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
p {
border-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
<h1>Hello</h1>
<p>World</p>