Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <main>
  <h1>Table with Nested Tables Hidden behind Expando Buttons</h1>
  <table id="Books">
    <caption>Books I May or May Not Have Read</caption>
    <tr>
      <th id="AuthMoreLbl"><span class="visually-hidden">More Books By</span></th>
      <th>Author</th>
      <th>Title</th>
      <th>Year</th>
      <th>ISBN-13</th>
      <th>ISBN-10</th>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth01" aria-controls="Auth01More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth01" onclick="toggle(this.id,'Auth01More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth01">Miguel De Cervantes</td>
      <td>The Ingenious Gentleman Don Quixote of La Mancha</td>
      <td>1605</td>
      <td>9783125798502</td>
      <td>3125798507</td>
    </tr>
    <tr style="display:none;" id="Auth01More">
      <td colspan="6">
        <table>
          <caption>Other Books by Miguel De Cervantes</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>La Galatea</td>
            <td>1585</td>
          </tr>
          <tr>
            <td>Novelas ejemplare</td>
            <td>1613</td>
          </tr>
          <tr>
            <td>Los trabajos de Persiles y Sigismunda</td>
            <td>1617</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth02" aria-controls="Auth02More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth02" onclick="toggle(this.id,'Auth02More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth02">Mary Shelley</td>
      <td>Frankenstein; or, The Modern Prometheus</td>
      <td>1818</td>
      <td>9781530278442</td>
      <td>1530278449</td>
    </tr>
    <tr style="display:none;" id="Auth02More">
      <td colspan="6">
        <table>
          <caption>Other Books by Mary Shelley</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>History of a Six Weeks’ Tour</td>
            <td>1817</td>
          </tr>
          <tr>
            <td>Mathilda</td>
            <td>1819</td>
          </tr>
          <tr>
            <td>Valperga; or, The Life and Adventures of Castruccio, Prince of Lucca</td>
            <td>1823</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth03" aria-controls="Auth03More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth03" onclick="toggle(this.id,'Auth03More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth03">Herman Melville</td>
      <td>Moby-Dick; or, The Whale</td>
      <td>1851</td>
      <td>9781530697908</td>
      <td>1530697905</td>
    </tr>
    <tr style="display:none;" id="Auth03More">
      <td colspan="6">
        <table>
          <caption>Other Books by Herman Melville</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>Typee: A Peep at Polynesian Life</td>
            <td>1846</td>
          </tr>
          <tr>
            <td>White-Jacket; or, The World in a Man-of-War</td>
            <td>1850</td>
          </tr>
          <tr>
            <td>The Confidence-Man: His Masquerade</td>
            <td>1857</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth04" aria-controls="Auth04More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth04" onclick="toggle(this.id,'Auth04More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth04">Emma Dorothy Eliza Nevitte Southworth</td>
      <td>The Hidden Hand</td>
      <td>1888</td>
      <td>9780813512969</td>
      <td>0813512964</td>
    </tr>
    <tr style="display:none;" id="Auth04More">
      <td colspan="6">
        <table>
          <caption>Other Books by Emma Dorothy Eliza Nevitte Southworth</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>Retribution; or The Vale of Shadows: A Tale of Passion</td>
            <td>1849</td>
          </tr>
          <tr>
            <td>Cruel as the Grave</td>
            <td>1871</td>
          </tr>
          <tr>
            <td>The Rejected Bride</td>
            <td>1894</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth05" aria-controls="Auth05More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth05" onclick="toggle(this.id,'Auth05More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth05">F. Scott Fitzgerald</td>
      <td>The Great Gatsby</td>
      <td>1925</td>
      <td>9780743273565</td>
      <td>0743273567</td>
    </tr>
    <tr style="display:none;" id="Auth05More">
      <td colspan="6">
        <table>
          <caption>Other Books by F. Scott Fitzgerald</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>This Side of Paradise</td>
            <td>1920</td>
          </tr>
          <tr>
            <td>The Beautiful and Damned</td>
            <td>1922</td>
          </tr>
          <tr>
            <td>Tender Is the Night</td>
            <td>1934</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
        <button type="button" id="btnAuth06" aria-controls="Auth06More" aria-expanded="false" aria-label="Show more by" aria-labelledby="AuthMoreLbl Auth06" onclick="toggle(this.id,'Auth06More');"><svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false"><path d="M70.3 13.8L40 66.3 9.7 13.8z"></path></svg></button>
      </td>
      <td id="Auth06">George Orwell</td>
      <td>Nineteen Eighty-Four</td>
      <td>1948</td>
      <td>9780451524935</td>
      <td>0451524934</td>
    </tr>
    <tr style="display:none;" id="Auth06More">
      <td colspan="6">
        <table>
          <caption>Other Books by George Orwell</caption>
          <tr>
            <th>Title</th>
            <th>Year</th>
          </tr>
          <tr>
            <td>Burmese Days</td>
            <td>1934</td>
          </tr>
          <tr>
            <td>Keep the Aspidistra Flying</td>
            <td>1936</td>
          </tr>
          <tr>
            <td>Animal Farm</td>
            <td>1945</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</main>
              
            
!

CSS

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

body {
  background-color: #eeeeee;
  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 1vw;
  margin: 1em 1vw;
  color: #000;
}

table {
  margin: 1em 0;
  border-collapse: collapse;
}

table table {
  margin: 0 0 1em 0;
}

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

.visually-hidden,
table table caption {
  position: absolute;
  top: auto;
  overflow: hidden;
  clip: rect(1px 1px 1px 1px); /* IE 6/7 */
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  white-space: nowrap;
}

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

table table th,
table table td {
  border: 0.01em solid #ccc;
}

td[colspan] {
  padding-left: 0.5em;
}

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

table table th {
  background-color: #757575;
}

tr:nth-child(odd) {
  border-bottom: 0.01em solid #ccc;
}

table table tr {
  border-bottom: none;
}

tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.01);
}

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

td:nth-of-type(3),
td td:nth-of-type(1) {
  font-style: italic;
}

td td:nth-of-type(3) {
  font-style: normal;
}

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

td button {
  font-size: 60%;
  color: #000;
  background-color: #00f;
  padding: 0.3em 0.2em 0 0.2em;
  border: 0.2em solid #00f;
  border-radius: 50%;
  line-height: 1;
  text-align: center;
  text-indent: 0;
}

button svg {
  width: 1em;
  height: 1em;
  fill: #fff;
  transition: transform 0.25s ease-in;
  transform-origin: center 45%;
}

td button:hover,
td button:focus {
  background-color: #fff;
  outline: none;
}

td button:hover svg,
td button:focus svg {
  fill: #00f;
}

button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

              
            
!

JS

              
                function toggle(btnID, eID) {
  var theRow = document.getElementById(eID);
  var theButton = document.getElementById(btnID);
  if (theRow.style.display == "none") {
    theRow.style.display = "table-row";
    theButton.setAttribute("aria-expanded", "true");
  } else {
    theRow.style.display = "none";
    theButton.setAttribute("aria-expanded", "false");
  }
}

              
            
!
999px

Console