htmlcssspacingline-height

Remove spacing between lines in CSS


I was trying to get rid of spacing between lines in one text element. I need to completely remove it or even get on the previous line. Property line-height doesn't work with negative numbers and I don't want to separate the element into several so margin and padding won't help either.

screenshot (I have to remove the red area)

<span id="my_line">lalalalalalalalala</span> <!--the word is cutting off-->
#my_line{
  overflow-wrap: break-word;
  line-height: 0; /* I need even less */
}

Solution

  • not a good answer but you can try this.

    you can use <p> and remove margin, padding and give it line-hight and font-size same for removing the space between lines. or you can decrease the line-height if you still see space between lines.

    <html>
    <head>
    <style>
    p{
    padding:0px;
    margin:0px;
    line-height:12px;
    font-size:14px
    }
    </style>
    </head>
    <body>
    
    <p>My First Heading My First Heading My first paragraph. My first paragraph. My first paragraph. My first paragraph.My My First Heading My first paragraph. My first paragraph. My first paragraph. My first paragraph.My first paragraph. My first paragraph. first paragraph. My first paragraph.</p>
    
    
    </body>
    </html>