I was wondering if it's a good idea to use CSS display property to emulate tables for a veeeery simple forum system.
I know this wasn't good thing to do like 2 years ago when IE and maybe others did not support display:table / table-cell etc. But I think now all browsers support it, right?
Setting display to table makes the element behave like a table. So you can make a replica of an HTML table without using the table element and corresponding elements such as tr and td . For example, in HTML, you can make a table with the <table> element and also a <div> , or any container of your choice.
The World Wide Web Consortium (W3C®) discourages use of tables for layout because they are striving for a web in which content and structure are completely separate from presentation.
If your intention is to display a table, an HTML table is your way to go. If your goal is to lay out content on a webpage, CSS grid is one way of doing that. It doesn't have perfect browser support yet so you might want to consider another option for layout, but it is an option. Tables were never meant for layout.
The display CSS property sets whether an element is treated as a block or inline element and the layout used for its children, such as flow layout, grid or flex. Formally, the display property sets an element's inner and outer display types.
If the information being displayed on the forum is tabular, then don't be afraid to use a table if it makes sense semantically.
For general page layout, personally I wouldn't use it. I'd stick to the typical block-level div layouts and floats. IE7 does not support display:table and there are other caveats, such as the fact that it will expand in width based on content. For the future, I look forward to when flexbox is fully supported.
I do occasionally use display:inline-block for centering dynamic list items and the like.
I wouldn't mix structure (HTML) with style (CSS). If it's tabular data, just use <table>
s if it's not, you're best bet would to use divs/CSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With