Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <main>
  <h1>Table Rows with Different Display Properties</h1>
  <p>
    For this example, individual rows are set to whatever <code>display</code> property you choose, which breaks the entire table structure. To demonstrate, the buttons below converts all but the header rows to whichever style you press.
  </p>
  <p>
    Note that only the first row (of data, not the header row) has ARIA properties set. These properties will retain semantics for all but <code>display: contents</code>, but can do nothing for the layout.
  </p>
  <p>
    <button onclick="ToggleRowDisplay('block',this);">Convert rows to <code>block</code>.</button>
    <button onclick="ToggleRowDisplay('inline',this);">Convert rows to <code>inline</code>.</button>
    <button onclick="ToggleRowDisplay('contents',this);">Convert rows to <code>contents</code>.</button>
    <button onclick="ToggleRowDisplay('table-row',this);">Reset rows to <code>table-row</code>.</button>
  </p>
  <div role="region" aria-labelledby="Cap1" tabindex="0" id="TableContainer">
    <table id="Books" role="table">
      <caption id="Cap1">Books I May or May Not Have Read</caption>
      <thead>
        <tr role="row">
          <th role="columnheader">Author</th>
          <th role="columnheader">Title</th>
          <th role="columnheader">Year</th>
          <th role="columnheader">ISBN-13</th>
          <th role="columnheader">ISBN-10</th>
        </tr>
      </thead>
      <tbody>
        <tr role="row">
          <td role="cell">Miguel De Cervantes</td>
          <td role="cell">The Ingenious Gentleman Don Quixote of La Mancha</td>
          <td role="cell">1605</td>
          <td role="cell">9783125798502</td>
          <td role="cell">3125798507</td>
        </tr>
        <tr>
          <td>Mary Shelley</td>
          <td>Frankenstein; or, The Modern Prometheus</td>
          <td>1818</td>
          <td>9781530278442</td>
          <td>1530278449</td>
        </tr>
        <tr>
          <td>Herman Melville</td>
          <td>Moby-Dick; or, The Whale</td>
          <td>1851</td>
          <td>9781530697908</td>
          <td>1530697905</td>
        </tr>
        <tr>
          <td>Emma Dorothy Eliza Nevitte Southworth</td>
          <td>The Hidden Hand</td>
          <td>1888</td>
          <td>9780813512969</td>
          <td>0813512964</td>
        </tr>
        <tr>
          <td>F. Scott Fitzgerald</td>
          <td>The Great Gatsby</td>
          <td>1925</td>
          <td>9780743273565</td>
          <td>0743273567</td>
        </tr>
        <tr>
          <td>George Orwell</td>
          <td>Nineteen Eighty-Four</td>
          <td>1948</td>
          <td>9780451524935</td>
          <td>0451524934</td>
        </tr>
      </tbody>
    </table>
  </div>
  <p>
    This pen is used in the post <cite><a href="http://adrianroselli.com/2018/05/layout-as-a-clue-to-semantics.html">Layout as a Clue to Semantics</a></cite>.
  </p>
</main>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Lato:400,400i,700");

body {
  background-color: #6d695c;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAA3RSTlMmDQBzGIDBAAAAG0lEQVR42uXIIQEAAADCMHj/0NdkQMws0HEeAqvwAUGJthrXAAAAAElFTkSuQmCC);
  font-size: 100%;
  color: #333;
  font-family: Lato, Arial, sans-serif;
  padding: 0;
  margin: 0;
}

main {
  display: block;
  box-sizing: border-box;
  width: auto;
  padding: 1em 2vw;
  margin: 1em 2vw;
  color: #000;
  background-color: rgba(204, 204, 204, 0.7);
  border: 0.07em solid rgba(0, 0, 0, 0.5);
  border-radius: 0.5em;
}

table {
  margin: 1em 0;
  border-collapse: collapse;
/*   width: 100%; */
}

caption {
  text-align: left;
  font-style: italic;
  padding: 0.25em 0.5em 0.5em 0.5em;
}

th,
td {
  padding: 0.25em 0.5em 0.25em 1em;
  vertical-align: text-top;
  text-align: left;
  text-indent: -0.5em;
}

th {
  vertical-align: bottom;
  background-color: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-weight: bold;
}

td::before {
  display: none;
}

tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.25);
}

tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.5);
}

td:nth-of-type(2) {
  font-style: italic;
}

th:nth-of-type(3),
td:nth-of-type(3) {
  text-align: right;
}

div {
  overflow: auto;
}

button {
  font-size: 90%;
  font-family: Lato, Arial, sans-serif;
  color: #fff;
  background-color: #00c;
  border: .1em solid #00f;
  border-radius: .5em;
  font-weight: bold;
  padding: .5em;
  text-align: center;
  box-shadow: .25em .25em .5em rgba(0, 0, 0, .5);
}

button[disabled] {
  background-color: #ccc;
  border-color: #ccc;
  color: #666;
}

button:not([disabled]):focus,
button:not([disabled]):hover {
  color: #00f;
  background-color: #fff;
  outline: 0;
}

button[aria-pressed=true] {
  background-color: #000;
  border-color: #000;
  color: #ccc;
}

button:active {
  box-shadow: 0 0 .5em rgba(0, 0, 0, .5);
}

p:nth-child(4) {
  display: flex;
  flex-wrap: wrap;
  margin: 1em 0em 0 0em;
}

p:nth-child(4) button {
  flex: 1 0 10em;
  margin: 0.5em;
}
              
            
!

JS

              
                function ToggleRowDisplay(CSSDisplay,selButton) {
  try {
    var theRows = document.querySelectorAll('tbody tr');
    for (var i = 0; i < theRows.length; i++) {
      theRows[i].setAttribute('style','display:' + CSSDisplay);
    }
    ToggleSelectedButton(selButton);
    document.getElementById('TableContainer').focus();
  } catch (e) {
    console.log("ToggleRowDisplay(): " + e);
  }
}

function ToggleSelectedButton(selButton) {
  try {
    var theButtons = document.querySelectorAll('button');
    for (var i = 0; i < theButtons.length; i++) {
      theButtons[i].setAttribute('aria-pressed','false');
    }
    selButton.setAttribute('aria-pressed','true');
  } catch (e) {
    console.log("ToggleSelectedButton(): " + e);
  }
}
              
            
!
999px

Console