Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <table data-component="table" id="table">
    <tr><th>Name</th><th>Known As</th><th>Year</th></tr>
    <tr><td>Bruce Wayne</td><td>Batman</td><td>1939</td></tr>
    <tr><td>Clark Kent</td><td>Superman</td><td>1938</td></tr>
    <tr><td>Tony Stark</td><td>Iron Man</td><td>1963</td></tr>
    <tr><td>Peter Parker</td><td>Spider-Man</td><td>1962</td></tr>
    <tr><td>Matt Murdock</td><td>Daredevil</td><td>1964</td></tr>
<p id="controls">
    Change hue / accent-color:
    <input type="range" oninput="'--tbl-hue', this.valueAsNumber);'--hue', this.valueAsNumber)" value="200" max="360">
    Change border-radius:
    <input type="range" oninput="'--tbl-bdrs', this.valueAsNumber+'rem')" value="0.5" max="2.5" step="0.25">
    Change border-width:
    <input type="range" oninput="'--tbl-bdw', this.valueAsNumber+'px')" value="1" max="20">


 * table.css
 * @version 1.0.1
 * @description Generic Table Component
:where([data-component="table"]) {
  --tbl-hue: 200;
  --tbl-sat: 60%;

  --tbl-bdc: hsl(var(--tbl-hue), var(--tbl-sat), 80%);
  --tbl-bdrs: 0.5rem;
  --tbl-bdw: 1px;
  --tbl-td-pb: 1.25ch;
  --tbl-td-pi: 2ch;
  --tbl-td-hover-bgc: hsl(var(--tbl-hue), var(--tbl-sat), 95%);
  --tbl-th-bgc: hsl(var(--tbl-hue), var(--tbl-sat), 40%);
  --tbl-th-c: hsl(var(--tbl-hue), var(--tbl-sat), 99%);

  background-color: var(--tbl-bgc, transparent);
  border-collapse: var(--tbl-bdcl, separate);
  border-radius: var(--tbl-bdrs);
  border-spacing: var(--tbl-col-gap, 0) var(--tbl-row-gap, 0);
  box-shadow: var(--tbl-bxsh, none);
  table-layout: var(--tbl-tbl, auto);
  width: var(--tbl-w, 99.9%);

:where([data-component="table"] thead th) {
  background-color: var(--tbl-th-bgc);
  border-style: var(--tbl-th-bds, solid);
  border-block-start-width: 0;
  border-inline-end-width: var(--tbl-bdw);
  border-block-end-width: 0;
  border-inline-start-width: 0;
  color: var(--tbl-th-c);
  font-weight: var(--tbl-th-fw, 700);
  overflow: hidden;
  padding-block: var(--tbl-td-pb);
  padding-inline: var(--tbl-td-pi);
  position: relative;
  text-align: var(--tbl-th-tal);
  text-overflow: ellipsis;
  text-transform: var(--tbl-th-tt, uppercase);
  white-space: nowrap;

:where([data-component="table"] td) {
  background-color: var(--tbl-td-bgc, #FFF);
  border-color: var(--tbl-bdc);
  border-style: var(--tbl-td-bds, solid);
  border-block-start-width: 0;
  border-inline-end-width: var(--tbl-bdw);
  border-block-end-width: var(--tbl-bdw);
  border-inline-start-width: 0;
  overflow: hidden;
  padding-block: var(--tbl-td-pb);
  padding-inline:	var(--tbl-td-pi);
  text-overflow: ellipsis;
  white-space: nowrap;

/* Because of `border-collapse: separate`, we need to  */
:where([data-component="table"] tr td:first-of-type) {
  border-inline-start-width: var(--tbl-bdw);
/* For header-cells, we set the `border-color` of the first and last border to it's `background-color` */
:where([data-component="table"] tr th:last-of-type) {
  border-inline-color: var(--tbl-th-bgc);
:where([data-component="table"] tr th:first-of-type) {
  border-inline-start-color: var(--tbl-th-bgc);
/* Set `border-radius` on first and last rows, on first and last cell */
:where([data-component="table"] thead th:first-of-type) {
  border-start-start-radius: var(--tbl-bdrs);
:where([data-component="table"] thead th:last-of-type) {
  border-start-end-radius: var(--tbl-bdrs);
:where([data-component="table"] tbody tr:last-of-type td:first-of-type) {
  border-end-start-radius: var(--tbl-bdrs);
:where([data-component="table"] tr:last-of-type td:last-of-type) {
  border-end-end-radius: var(--tbl-bdrs);

/* Optionally, set text-alignment and/or width per column */
[data-component="table"] tr > *:nth-of-type(1) { text-align: var(--ca1, initial); width: var(--cw1, initial); }
[data-component="table"] tr > *:nth-of-type(2) { text-align: var(--ca2, initial); width: var(--cw2, initial); }
[data-component="table"] tr > *:nth-of-type(3) { text-align: var(--ca3, initial); width: var(--cw3, initial); }
[data-component="table"] tr > *:nth-of-type(4) { text-align: var(--ca4, initial); width: var(--cw4, initial); }

@media (hover: hover) {
  :where([data-component~="table"]) tr:hover td {
    --tbl-td-bgc: var(--tbl-td-hover-bgc);

/* For demo */
body {
  font-family: ui-sans-serif, sans-serif;
  margin-block: 2ch;
  margin-inline: auto;
  max-inline-size: 64rem;
  padding-inline: 2ch;

input {
  accent-color: hsl(var(--hue, 200), 60%, 50%);
  display: block;
  margin-block-end: 2ch;
  width: 12rem;

label {
  font-size: 80%;
  font-weight: 500;

p {
  display: flex;
  gap: 2ch;

@media screen and (min-width: 48rem) {
  p { flex-flow: row; }