Skip to content Skip to sidebar Skip to footer

Can I Use Table-cell As A Stand Alone Style?

When using the CSS display:table-cell on an element, is it somehow preferred/required that it's parent elements have display:table-row, and display:table? Can this stand alone in a

Solution 1:

You are free to do it either way. If table and table-row elements are not provided, anonymous ones will be inserted for you (as long as the browser follows the W3C specification).

http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes

Any table element will automatically generate necessary anonymous table objects around itself, consisting of at least three nested objects corresponding to a 'table'/'inline-table' element, a 'table-row' element, and a 'table-cell' element.

Keep in mind that anonymous elements cannot be styled. This is only an issue if there isn't enough content within your table-cell elements for them take up 100% of their parent's width. In this case, only a table element is necessary, you can drop the table-row.

Post a Comment for "Can I Use Table-cell As A Stand Alone Style?"