Why can't I decrease the line-height of this text?

CssEm

Css Problem Overview


http://jsfiddle.net/mJxn4/

This is very odd: I have a few lines of text wrapped in an <em> tag. No matter what I do, lowering the value for line-height below 17px has no effect. I can bump the line-height up to greater than 17px and it'll apply, but I can't get it lower than 17px.

The CSS in question is:

#others .item em {
    font-size: 13px;
    line-height: 17px;
}

Try adjusting the line height both higher and lower and run the updated fiddle after each change, and you'll see what I mean.

Why would this be? No line-height is specified anywhere else in the CSS, so nothing is overriding it. That couldn't be the case anyway because I'm adjusting the line-height up and down within the same selector, so it doesn't make sense that a higher value would apply, but a lower value would get overridden.

Css Solutions


Solution 1 - Css

Because the em tag is inline and its line-height cannot be lower than its parent div.

For example, if you set the line-height of the parent to 10px, then you would be able to decrease the line-height of em tag to 10px as well.

Solution 2 - Css

In order for line-height property to work, div should has display property equal to block

.app-button-label{
    line-height: 20px;
    display: block;
 }

Solution 3 - Css

I was facing this problem with divs in mobile view - the line height was way too big and line-height wasn't working! I managed to make it work by adding "display:block", per advice here: https://stackoverflow.com/questions/7424867/why-isnt-the-css-property-line-height-not-letting-me-make-really-tight-line-s

Hope this helps anyone else facing the same problem in future

Solution 4 - Css

You seem to be using normalized css option in jsfiddle - which equates to the CSS rules being reset - ala http://meyerweb.com/eric/tools/css/reset/

You can either reset the reset, or use a different reset if you really need it.

See here for more details:

http://sixrevisions.com/css/a-comprehensive-guide-to-css-resets/

Solution 5 - Css

The best way to do it is using css reset.

Write your own or use popular one like

http://meyerweb.com/eric/tools/css/reset/

Solution 6 - Css

The simplest way is to specify the line height with a higher priority, for example you could write: line-height: 14px !important;

If it is still not working set high priority in both where you u would like to decrease the line height (inline css) and also put in the body css .. remember the high priority (!important;) because it overrides any other unknown css rules.

Hope this helps

Ahmed

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondaGUYView Question on Stackoverflow
Solution 1 - CssIbuView Answer on Stackoverflow
Solution 2 - CssRamesh VishnoiView Answer on Stackoverflow
Solution 3 - CssGraceView Answer on Stackoverflow
Solution 4 - Cssjrd1View Answer on Stackoverflow
Solution 5 - Cssuser1607528View Answer on Stackoverflow
Solution 6 - CssAhmed ShahinView Answer on Stackoverflow