When used on their own, display: table
and display: table-cell
behave differently in different browsers.
Environment
I did my testing in three different environments :
Environment 1 :
- OS : Linux Ubuntu Desktop 14, 64-bit
- Browser 1 : Chrome 45.0
- Browser 2 : Firefox 43.0
Environment 2 :
- OS : Windows 7, 64-bit
- Browser 1 : Chrome 48.0
- Browser 2 : Firefox 44.0
Environment 3 :
- OS : Windows 10, 64-bit
- Browser 1 : Chrome 51.0
- Browser 2 : Firefox 47.0
Case 1 - display: table
& box-sizing: content-box
.container {
display: table;
width : 500px;
height: 150px;
background: #ccf;
}
.content {
color: #000;
height : 100%;
padding: 20px;
background: #ffc;
}
<div class="container">
<div class="content">
Lorem Ipsum
</div>
</div>
In FireFox, I'm getting the following output :
In Chrome, I'm getting the following output :
See also this Fiddle.
Case 2 - display: table
& box-sizing: border-box
.container {
display: table;
width : 500px;
height: 150px;
background: #ccf;
}
.content {
color: #000;
height : 100%;
padding: 20px;
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #ffc;
}
<div class="container">
<div class="content">
Lorem Ipsum
</div>
</div>
In FireFox, I'm getting the following output :
In Chrome, I'm getting the following output :
See also this Fiddle.
Case 3 - display: table-cell
& box-sizing: content-box
.container {
display: table-cell;
width : 500px;
height: 150px;
background: #ccf;
}
.content {
color: #000;
height : 100%;
padding: 20px;
background: #ffc;
}
<div class="container">
<div class="content">
Lorem Ipsum
</div>
</div>
In FireFox, I'm getting the following output :
In Chrome, I'm getting the following output :
See also this Fiddle.
Case 4 - display: table-cell
& box-sizing: border-box
.container {
display: table-cell;
width : 500px;
height: 150px;
background: #ccf;
}
.content {
color: #000;
height : 100%;
padding: 20px;
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #ffc;
}
<div class="container">
<div class="content">
Lorem Ipsum
</div>
</div>
In FireFox, I'm getting the following output :
In Chrome, I'm getting the following output :
See also this Fiddle.
My question(s) :
- Do the specs define how
display : table
,display : table-row
anddisplay : table-cell
should behave when used independently from each other? If yes, which of these is the expected behavior? - Are these browser differences caused by a bug in either Chrome of Firefox? And if these browser differences are caused by a bug, is the dev team of either browser trying to get this fixed?
- While these browser differences persist, what strategies for normalizing behavior across browsers should I consider?
display : table
anddisplay : table-cell
as stand-alone statements in other people's code all the time. I guess they ARE kind of hacks, really, but this is the first time that I see anyone argue it is improper use of CSS. That IS what you're saying, right? – Subdue