skip to Main Content

How can I remove top and bottom spaces from text in HTML?

Currently, the only approach I have found online is using the CSS property ‘line-height’. In the backend, I am using C# to obtain the font’s height through ‘GlyphTypeface.CapsHeight’ and adjust the CSS ‘line-height’ accordingly.

style = $"line-height: {font.CapsHeight}em;"

I want to achieve a similar text style to that of Photoshop, as shown in the attached image.
Left side is HTML and right side is Photoshop Text
HTML comparison with photoshop sample

Are there any alternative methods to remove top space, or other ways to achieve text formatting similar to the image without spaces?

2

Answers


  1. To remove unwanted spacing around text in HTML, you can use the CSS padding properties or by using bootstrap class.

    To remove the margin around an element, you can

    1. Set its padding property to 0 as "style:padding=0"
    2. By add mx-auto or px-px-auto to the div class of the text
    Login or Signup to reply.
  2. here’s what you want
    Remove white space above and below large text in an inline-block element
    Remove white space above and below large text in an inline-block element

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search