- var n = 0;
table
  thead
    tr
      th(colspan=3) All
    tr
      th(colspan=2) First two
      th(rowspan=2) Third
    tr
      th First
      th Second
  tbody
    while n < 128
      - n++
      tr
        td Cell #{n}.1
        td Cell #{n}.2
        td Cell #{n}.3
View Compiled
:root {
  --border-width: 2px;
  --border-color: #CED4DA;
  --border: var(--border-width) solid var(--border-color);
}

/* Sticky header */
table {
  border-collapse: separate;
  border-spacing: 0;
}

thead {
  position: sticky;
  top: 0;
}

th, td {
  border-right: var(--border);
  border-bottom: var(--border);
}

th:first-child, td:first-child {
  border-left: var(--border);
}

thead tr:first-child th {
  border-top: var(--border);
}

/* Other styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial,
    sans-serif;
  margin: 0;
}

table {
  width: 100%;
}

th {
  text-align: left;
  background-color: #f1f3f5;
}

th, td {
  padding: 3px 5px;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.