line-height was just simply used on a div in that example
Which is valid, because the line-height property inherits from the parent element and applies to all elements
No where does it say ..."line-height is used with a div, not p"
When you learn to consult with the real specs you will get the real answers
line-height - CSS | MDN
* Initial value - normal
* Applies to - all elements. It also applies to ::first-letter and ::first-line.
* Inherited - yes
* Percentages - refer to the font size of the element itself
* Media - visual
* Computed value - for percentage and length values, the absolute length, otherwise as specified
* Animation type - either number or length
* Canonical order - the unique non-ambiguous order defined by the formal grammar