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

  • SEARCH
  • Home
  • 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 8551663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:14:39+00:00 2026-06-11T14:14:39+00:00

I am having a hard time understanding how font-size is working in the following

  • 0

I am having a hard time understanding how font-size is working in the following html snippet:

.container {
    padding: 20px;
}

ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

ul li {
    margin: 0;
    padding: 0;
    background: blue;
    height: 50px;
    line-height: 50px;
    color: white;
}

ul li span {
    border: 1px solid red;
    margin: 0;
    padding: 0;
}

#test1 li {
    font-size: 48px;
}

#test2 li {
    font-size: 42px;
}​

<div class="container">
    <ul id="test1">
        <li><span>Test</span></li>        
    </ul>
</div>

<div class="container">
    <ul id="test2">
        <li><span>Test</span></li>
    </ul>
</div>​

I want my li element to be exactly 50 pixels tall, and I want the text/span to be centered vertically within it. Everything is vertical, but when I set font-size to 48px with a 2px red border, the border is pushed outside of the li element. It almost seems like there is an invisible padding/margin applied.

Here is a jsfiddle demonstrating the “issue”: http://jsfiddle.net/qtVK3/

When I inspect the span element in Chrome, it shows the actual height of the span element is 57px. Where does the extra 7px come from?

  • 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-06-11T14:14:41+00:00Added an answer on June 11, 2026 at 2:14 pm
    display: inline-block
    

    Is needed in the span because it is an inline elements. By default you cannot add top or bottom padding to an inline element only left and right. So the span will be padded even if you put padding to 0.

    Also you need to change your line-height to 48px.

    line-height: 48px;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time understanding why the following code doesn't work. I'm sure
I'm having a hard time understanding the following statements from Algorithms by S. Dasgupta,
I'm having a hard time understanding the size parameter of mmap (sorry my C
I am having a hard time understanding symbols in Scheme. The following confuses me:
I'm having a hard time understanding this. Consider the following example: protected void Page_Load(object
I'm having a hard time understanding why the following expression \\[B.+\\] and code returns
I am having a hard time understanding the following syntax in Verilog: input [15:0]
I'm having hard time understanding the following C# code. This code was taken from
Im having a hard time understanding the limits and possibilities of an IF statement.
I am having a hard time understanding the nuances of git-fetch. I understand that

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.