CSS: display:block; vs display:table;

Both will be block-level, in that they won’t display next to anything else, by default.

There is a significant difference in the actual display of the element. display: block; will extend to 100% of the available space, while display: table; will only be as wide as its contents.

Also, as others have mentioned, display: table; is required to get display: table-cell; or other table- stuff to work in the descendents.

I only know this because I just ran into the problem of trying to get the display: table; to fill the width of the container. I haven’t been able to see if there is a difference in the display of display: inline; and display: inline-table;.

https://jsfiddle.net/nnbonhc6/

Leave a Comment