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 8908513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:11:55+00:00 2026-06-15T03:11:55+00:00

I just stumbled over a very strange behavior with a layout which uses the

  • 0

I just stumbled over a very strange behavior with a layout which uses the table-cell css property. I tried the following code in current FF, Safari and Chrome. The behavior is the same everywhere.

My questions is whether someone knows why this happens. Is it a browser bug or a defined behavior? I found this question which has a hint on how to solve the problem, but I would rather like to know why this is happening in the first place. I think other people would also like to know.

Problem: If I comment in the   in the second table-cell, everything is fine. If, however the div stays empty the content of the two other cells has something like an “offset-top”. This offset has the same dimension as the height of the middle cell. I.e. the content of the outer cells is shifted to the bottom. I added two screenshot div_not_empty.png and div_empty.png.

thanks

Update
I forgot the screenshots. Here they are:
Div is empty
Div is not empty


Code:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Strange behavior with table-cell formatting</title>
    <style type="text/css" media="screen">
      #table {
        display:    table;
        background: #efefef;
      }
      div.cell {
        display:    table-cell;
      }
      #c1 div.content {
        width:    200px;
      }
      #c2 {
        border-left: 2px solid #ccc;
      }
      #c2 div.content {
        height:   150px;
        width:    150px;
        background: #aaa;
        vertical-align: bottom;
      }
      #c3 {
        width:    200px;
        border-left: 2px solid #ccc;
      }
    </style>
  </head>
  <body>
    <div id="table">
      <form id="c1" class="cell">
        <div class="content">
          Lorem ipsum dolor sit amet, consectetur adipisicing 
          elit, sed do eiusmod tempor incididunt ut.
        </div>
      </form>
      <div id="c2" class="cell">
        <div class="content">
          <!-- &nbsp; -->
        </div>
      </div>
      <div id="c3" class="cell">
        <div class="content">
           Dolore magna aliqua. Ut enim ad minim veniam, 
           quis nostrud exercitation ullamco laboris nisi ut 
           aliquip ex ea commodo consequat. Duis aute irure 
           dolor in reprehenderit.
        </div>
      </div>
    </div>
  </body>
</html>
  • 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-15T03:11:57+00:00Added an answer on June 15, 2026 at 3:11 am

    It’s got to do with the way that vertical-align: bottom is calculated – see the mdc docs, when applied to table cells, bottom “Aligns the bottom padding edge of the cell with the bottom of the row”.

    When the table cell has no content, padding is not drawn in the box (i.e. when when 0, if there is content, the browser calculates where the padding would be).

    With a &nbsp; element, there is content to use as the basis for the alignment; without it you’ll notice the browsers line the bottom of the element itself up with the bottom of the first line of content in the other elements.

    re: the question you link to, using vertical-align: top works because the layout is calculated based on the top of the block elements, not the content they contain.

    A simple fix for the issue is to add padding to the .content divs in your stylesheet, which then causes them to render as if they have content, meaning you don’t need to have &nbsp;‘s in your code when there’s nothing to display:

      div.content {
        height:   150px;
        padding-bottom: 1px;
      }
    

    Try this and you’ll see it behaves as you expect.

    So; not really a browser bug, as the browser is trying to calculate the position based on the content (or, bottom of padding) of an element, and the element has no content. Possibly an unintended side-effect of the spec in this case though.

    On a related note, your css rule div.cell isn’t matching the first ‘cell’ which is a form element. It’s working because all elements inside a display: table element have display: table-cell applied automatically, but not the best.

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

Sidebar

Related Questions

I just stumbled over a very interesting problem. Giving the following code: using System;
I just stumbled upon a behavior which surprised me: When writing: int x =
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I just stumbled over the following line of code cout << &Blahh << endl;
I've just stumbled over a line in Java 6 which function is not clear
I've just stumbled over another question in which someone suggested to use new ASCIIEncoding().GetBytes(someString)
Ive just stumbled across property on a text box and it sounds the ideal
I just read this question and stumbled upon the following quote: Scala treats ==
I just stumbled over a small problem when extending javascript objects using jQuery. When
I just converted a code snippet from VB.NET to C# and stumbled over this

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.