I'm trying to restrict each header and paragraph to only be apart of one column instead of auto formatting to go to the next column when it runs out of room.
.columns {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
.div1 {
width: 100%;
padding: 10px;
border-right: 2px solid;
border-left: 2px solid;
margin: 0;
background-color: white;
}
<div class="div1">
<div class="columns">
<h4>Landscaping</h4>
<p>As Northeast Ohio Landscapers, Hemlock Landscapes has been caring for customers and their properties throughout the Chagrin Valley since 1981.
Our core values:
Bring a positive attitude with you each and every day
Work hard, pitch in, be helpful and productive
Be fair and respectful with all people in all encounters</p>
<h4>Services</h4>
<p>When it comes to Residential Landscape Maintenance in Northeast Ohio, we have a pretty simple mission.
Our mission is to unite people in positive relationships to improve lives.
This includes not only our great customers but also our fantastic employees and vendors that we work with each and every day. If we are not improving your life then we are not living up to our mission.
Experienced in every facet of the landscape industry, we fulfill our one company… total care philosophy by meeting your every need in the following areas:
Residential Landscape Maintenance
Landscape Design/Installation
Plant Health Care</p>
<h4>Mission</h4>
<p>Whether you are new to the Chagrin Valley, switching landscape service providers, or need to add a service to your existing account, Hemlock Landscapes makes it easy for you.</p>
</div>
</div>
Set a display: inline-block
to each <p>
element. This way, they will be self-contained in their respective column. But please bear in mind that this will not prevent the header from spilling to other columns, as seen in this image:
But, if you can wrap each header-column pair with a <div>
, then you will just have to apply the display: inline-block;
to that container, as seen in this image:
Or, as torazaburo pointed out, you could use break-inside: avoid;
to prevent the splitting of the element. I'm used to using display: inline-block
as it also trims unwanted size from the elements and make them easier to manage (in this case, it even make sense to have them like that as you are declaring a column layout), but the other property provides the exact same feature for your specific case.