I have a variety of paragraphs on my page, with some being lengthy and others very short. I have applied the common property of column-count: 2
to all paragraphs, but I am facing an issue where I do not want to split a paragraph into two columns if it consists of only two or three lines.
Below is the code snippet:
p {
column-count: 2;
}
<h2>First paragraph (needs to be two columns)</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h2>Second one (no need of column)</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the </p>
In my content, the first paragraph is long and should be displayed in two columns. However, the second paragraph is short and should not be split into two columns.
Here is a Demo demonstrating a minimal working code example.
Please note that I am unable to predict in advance which paragraphs will be long or short as they are generated dynamically from the server.
Edit: Since my actual code contains over 100 paragraphs, I am looking for a CSS-only solution to address this issue (if possible).