Pure CSS Table

, , …,

This page is a example of using CSS to format tabular data, without using the HTML <table> tag.

Here's a example of CSS table rendered in your browser:

one
two
three
four
five
six

Here's the HTML code:

<div class="a">
  <div class="b">
    <div class="c1">one</div>
    <div class="c2">two</div>
  </div>
  <div class="b">
    <div class="c1">three</div>
    <div class="c2">four</div>
  </div>
  <div class="b">
    <div class="c1">five</div>
    <div class="c2">six</div>
  </div>
</div>

Here's the CSS code:

.a, .b, .c1, .c2 {border:solid thin red}
.a {display:table}
.b {display:table-row}
.c1, .c2 {display:table-cell}

(For the complete raw HTML file, see: CSS Table Example.)

Here's a full list of values for the display attribute to emulate table tags.

Basic HTML Table 「display」 values
CSSHTML
display:tableHTML table
display:table-rowtr (row)
display:table-celltd (table cell)
caption, header, footer, 「display」 values
CSSHTML
display:table-captioncaption
display:table-header-groupthead (table header row; th group)
display:table-footer-grouptfoot (table footer row)

〔☛ HTML Table Examples with thead, tbody, tfoot

column, row, group 「display」 values
CSSHTML
display:table-row-grouptbody
display:table-columncol
display:table-column-groupcolgroup

〔☛ HTML Table Examples with colgroup and col

blog comments powered by Disqus