my text in the p element is overwriting over next p element when I use line-height to 2px, I am new to coding please help here’s the code
.main-section p{
font-size: 16px;
word-spacing: 1px;
line-height: 2px;
color: #252426;
}
<section class="main-section" id="introduction">
<h2>Introduction</h2>
<p>JavaScript is a cross-platform, object-oriented scripting language....JavaScript is a cross-platform, object-oriented scripting language....JavaScript is a cross-platform, object-oriented scripting language....JavaScript is a cross-platform, object-oriented scripting language....word limit</p>
<p>JavaScript contains a standard library of objects, such as Array...JavaScript contains a standard library of objects, such as Array...JavaScript contains a standard library of objects, such as Array...word limit</p>
paragraph overwriting
3
Answers
line-height
property calculates it from the beginning of the first line to the beginning of the next line so when you give it1px
it will overlap when the space is less than the height of the font’s sizeyou can use a multiplier value like:
if you want 1px line height use
calc()
function:Just remove the line-height property to make it auto-measure.