Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:19:05+00:00 2026-05-26T22:19:05+00:00

Line-height causes gaps between images and other elements but changing its value to 0

  • 0

Line-height causes gaps between images and other elements but changing its value to 0 makes any text impossible to read, is there any easy fix for that?

Imagine some repeatable DOM element like a shadow, how would you erase gap between this element and anything that is above (may be an image, div, span, button, form)?

Setting class for this .shadow and giving it line-height of 0 of course doesn’t work as line-height works a bit differently.

I made 3 images, the first one shows what I’m talking about, the second one fixes it, the third one shows how the second one in fact destroyed the whole layout:

http://jsfiddle.net/J5PLf/

I’m thinking about something like:

body {
   line-height: 0;
}

p {
   line-height: 1.2em;
}

But I guess it’s a bit risky, what if there will be some free text not within

tags?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:19:06+00:00Added an answer on May 26, 2026 at 10:19 pm

    Don’t mess with the line-height propety, and set display:block at the images.

    Fiddle: http://jsfiddle.net/J5PLf/1/

    #example1, #example2, #example3 {
        width: 200px;
        float: left;
    }
    img {
        display:block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you increase the line-height of an element, you start getting gaps between each
The line-height property usually takes care of vertical alignment, but not with inputs. Is
What is the best value for font size and line height where readability is
Is it good to add line-height in body{line-height:1.5} or it would be better if
I have tried setting a line-height for sIFR3 in both the sifr-config.js and my
How can I change the line-height of a PDF font or paragraph using iTextSharp?
Firefox 3 has introduced a new behavior in which line-height, when unset, differs from
<div style=width: 100px; height:50px; line-height:50px; overflow:hidden;> <p>A short line</p> </div> <div style=width: 100px; height:50px;
Whats the best approach to vertically center text in a li but restrict the
Setting two or more elements of a linear layout the same height seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.