I need your help, I have 2 html elements h3 and p
<h3>Samsung Galaxy F22 launched in India: Price, features, other details</h3>
<p>Samsung Galaxy F22 has been launched in India. The new smartphone has been priced in the mid-range segment. The new smartphone is powered by a MediaTek chipset and features a high refresh rate AMOLED display.</p>
These 2 elements are located in a container limited in height and width (w: 376, h: 191)
I use css to automatically add to h3 and p dots at the end
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
What is the main question, how to change the -webkit-line-clamp of the p element depending on the height\the number of rows of h3?
I need if h3 accepts 2 newline, then only 1 newline should be allowed in p, but if there is only 1 newline in h3, then 2 should be used in p so that there are always no more than 5 lines in total.