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 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

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

              
                <h1>Fill in the __BLANKS__ to fix these tests</h1>

<table id="one-caption">
  <caption>Fixture table caption</caption>
</table>

<table id="two-captions">
  <caption>Fixture table caption</caption>
  <caption>A second caption element</caption>
</table>

<table id="zero-captions"></table>

<table id="descendent-caption">
  <tr>
    <td>
      <table>
        <caption>Nested caption</caption>
      </table>
    </td>
  </tr>
</table>
              
            
!

CSS

              
                
              
            
!

JS

              
                
  test(function() {
    var table = document.getElementById('one-caption');

    table.deleteCaption();
    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, 'caption was removed');

  }, 'deleteCaption() delete only caption on table');

  test(function() {
    var table = document.getElementById('one-caption');
    var result;

    result = table.deleteCaption();
    assert_equals(result, __WHAT_IS_THE_RETURN_VALUE__, '.deleteCaption() returns undefined');
  }, 'deleteCaption() returns undefined');

  test(function() {
    var table = document.getElementById('two-captions');

    table.deleteCaption();
    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, '1 caption (of 2) was removed');
    assert_equals(table.getElementsByTagName('caption')[0].textContent, __WHAT_IS_THE_TEXT_OF_THIS_CAPTION__, 'The first caption was removed');

    // removing the only caption
    table.deleteCaption();
    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, 'last caption was removed');
  }, 'deleteCaption()');

  test(function() {
    var table = document.getElementById('zero-captions');
    // removing a caption when none exists
    table.deleteCaption();

    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, 'no exceptions using .deleteCaption() on a table without any captions');

  }, 'deleteCaption() does not throw any exceptions when called on a table without a caption');

  test(function() {
    var table = document.getElementById('descendent-caption');
    table.deleteCaption();

    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, 'descendent caption was not deleted');
  }, 'deleteCaption() does not delete captions in descendent tables');

  test(function() {
    var table = document.getElementById('zero-captions');
    var caption;

    caption = document.createElementNS('http://www.w3.org/2000/svg', 'caption');
    table.insertBefore(caption, table.firstChild);
    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS__, 'SVG:caption is created');

    table.deleteCaption();
    assert_equals(table.getElementsByTagName('caption').length, __HOW_MANY_CAPTIONS_ARE_LEFT__, 'SVG:caption is not deleted');

  }, 'deleteCaption() handles captions from different namespaces');
              
            
!
999px

Console