I’ll give you a slightly different option because it’s not using table is using UL/LI
Notice that with the rule height: calc(1.2em * 4);
I use as base the height of the source itself with units em
(already considering the line-height
standard of 20%), and multiplicity by * 4
, to have the height of the list, and with the flex-direction: column;
and the flex-wrap: wrap;
I’m breaking into columns next to each other.
See the example to better understand. And you can change the size of font
pq will always break in the fourth line pq the height is based on the font size using em
ul {
display: flex;
flex-wrap: wrap;
flex-direction: column;
font-size: 32px;
height: calc(1.2em * 4);
}
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
<li>item 6</li>
<li>item 7</li>
<li>item 8</li>
<li>item 9</li>
</ul>
Depends on the user agent. Desktop browsers (including Firefox) use a default value of roughly 1.2
, Depending on the element’s font-family
.
"Depends on the user agent. Desktop browsers (including Firefox) use a default value of approximately 1.2
, depending on the font-family
of the element."
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#Values
OBS: For more details about the unit EM
read here: Why it is recommended to use the "em" unit instead of "px" for fonts?
That is not the role of a table... It would be better to use a
<ol>
or<ul>
– Leandro Angelo
@Leandroangelo but using an ol/ul I can break every 4 lines?
– Dênis Azevedo