Why does Chrome give me a width of 0 for this table cell?

I decided that I was asking this question only to find out if anyone knew why this happened - although I'm sure this is a bug with Chrome.

Version of Chrome used: Version 30.0.1599.69 m (latest version at the time of publication)

Here is a fiddle that demonstrates:

http://jsfiddle.net/Dz4Q5/

HTML

<table id="myTable">
<tbody>
    <tr>
        <td id="testWidth">
            This should have some width
        </td>
    </tr>
</tbody>
</table>

CSS

#myTable {
  background-color:#4679bd
}
#testWidth {
 padding: 0;
 width: 0;
}

Javascript

var width = document.getElementById('testWidth').offsetWidth;
document.getElementById('width').innerHTML = width + 'px';

A blue frame containing text appears on the page. Obviously, this blue box has some width - as it takes up space. But CSS set the width to 0, which should actually be just a sentence, while the table cell will actually get its width from some child that clicked it.

Somehow javascript says that offsetWidth of a cell table is 0.

- . , Chrome v29 .

, Chrome v30 .

- , ? , , Chrome ?

, offsetWidth, ?

W3C - , ?

- , Chrome , , 0 CSS, , .

: #testWidth, , 10px 0, 10. , offsetWidth width CSS, ... right??

+4
2
0

CSS. width: 0; CSS.

CSS , .

#myTable {
  background-color:#4679bd
}
#testWidth {
  padding: 0;
}
0

All Articles