cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <table id="browsers">
  <caption id="Cap1">Default browser placeholder contrast ratios</caption>
    <tr>
      <th>Browser Engine</th>
      <th>Example</th>
      <th>Placeholder Color</th>
      <th>Background Color</th>
      <th>Contrast Ratio</th>
    </tr>
    <tr>
      <td><a href="https://en.m.wikipedia.org/wiki/Blink_(web_engine)">Blink</a></td>
      <td><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/default-placeholder-blink.png" alt="Default placeholder styling on an input for a WebKit browser. Screenshot." /></td>
      <td><code>#757575</code></td>
      <td><code>#FFFFFF</code></td>
      <td><a href="https://webaim.org/resources/contrastchecker/?fcolor=757575&bcolor=FFFFFF">4.61:1</a></td>
    </tr>
    <tr>
      <td><a href="https://en.m.wikipedia.org/wiki/EdgeHTML">EdgeHTML</a></td>
      <td><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/default-placeholder-edgehtml.png" alt="Default placeholder styling on an input for an EdgeHTML browser. Screenshot." /></td>
      <td><code>#666666</code></td>
      <td><code>#FFFFFF</code></td>
      <td><a href="https://webaim.org/resources/contrastchecker/?fcolor=666666&bcolor=FFFFFF">5.74:1</a></td>
    </tr>
    <tr>
      <td><a href="https://en.m.wikipedia.org/wiki/Gecko_(software)">Gecko</a></td>
      <td><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/default-placeholder-gecko.png" alt="Default placeholder styling on an input for a Gecko browser. Screenshot." /></td>
      <td><code>#777777</code></td>
      <td><code>#FFFFFF</code></td>
      <td><a href="https://webaim.org/resources/contrastchecker/?fcolor=7777777&bcolor=FFFFFF">4.48:1</a></td>
    </tr>
    <tr>
      <td><a href="https://en.m.wikipedia.org/wiki/Trident_(layout_engine)">Trident</a></td>
      <td><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/default-placeholder-gecko.png" alt="Default placeholder styling on an input for a Trident browser. Screenshot." /></td>
      <td><code>#666666</code></td>
      <td><code>#FFFFFF</code></td>
      <td><a href="https://webaim.org/resources/contrastchecker/?fcolor=666666&bcolor=FFFFFF">5.74:1</a></td>
    </tr>
    <tr>
      <td><a href="https://en.m.wikipedia.org/wiki/WebKit">WebKit</a></td>
      <td><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/default-placeholder-webkit.png" alt="Default placeholder styling on an input for a WebKit browser. Screenshot." /></td>
      <td><code>#A9A9A9</code></td>
      <td><code>#FFFFFF</code></td>
      <td><a href="https://webaim.org/resources/contrastchecker/?fcolor=A9A9A9&bcolor=FFFFFF">2.35:1</a></td>
    </tr>
</table>

            
          
!
            
              // Variables
$cell-padding: 1em;
$weight-bold: 400;


// Setup
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  background-color: #ffffff;
  color: #333333;
  font-size: 1em;
  font-family: 'Roboto Slab', serif;
  font-weight: 300;
  letter-spacing: -0.25px;
  padding: 2em;
}

a {
  color: #027abb;
  
  &:hover {
    text-decoration: none;
  }
  
  &:active,
  &:focus {
    background-color: #d33a2c;
    color: #ffffff;
    outline: 0.5em solid #d33a2c;
  }
}

img {
  width: 12em;
}

code {
  background: #f6f3f2;
  color: #333333;
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  font-size: 85%;
  font-variant-ligatures: none;
  hyphens: none;
  letter-spacing: 0.5px;
  padding: 0.25em 0.5em;
  text-shadow: 0 1px #fff;
  word-break: normal;
  word-spacing: normal;
  word-wrap: normal;
}


// Styling
table {
  border-collapse: collapse;
  width: 100%;
}

caption {
  color: #444333;
  font-size: 1.2em;
  font-weight: $weight-bold;
  letter-spacing: 1px;
  margin-bottom: 1em;
  text-align: left;
  text-transform: uppercase;
}

tr {
  border-bottom: 1px solid #dddddd;
  &:last-of-type {
    border-bottom: none;
  }
}

th,
td {
  padding: $cell-padding;
  text-align: left;
  
  &:nth-child(n+3) {
    text-align: right;
  }
}

th {
  font-weight: $weight-bold;
  vertical-align: bottom;
}

td::before {
  display: none;
}

@media screen and (max-width: 50em) {
  img {
    max-width: 100%;
  }

  code {
    align-self: end;
  }

  caption {
    margin-bottom: $cell-padding / 2;
  }

  th,
  tr:first-of-type {
    display: none;
  }
  
  tr {    
    td:last-of-type {
      padding-bottom: $cell-padding * 1.5;
    }
    
    td:first-of-type {
      padding-top: $cell-padding * 1.5;
    }
  }

  td {
    display: grid;
    grid-gap: $cell-padding;
    grid-template-columns: 0.55fr 1fr;
    justify-items: start;
    padding: $cell-padding / 2;
    
    &::before {
      display: inline;
      font-weight: $weight-bold;
      text-align: left;
    }
  }
}

@media screen and (max-width: 30em) {
  td {
    grid-template-columns: 1fr 1fr;
  }
}
            
          
!
            
              /* 
 / Adrian Roselli's accessible responsive table solution:
 / http://adrianroselli.com/2017/11/a-responsive-accessible-table.html
*/
function ResponsiveCellHeaders(elmID) {
  try {
    var THarray = [];
    var table = document.getElementById(elmID);
    var ths = table.getElementsByTagName("th");
    for (var i = 0; i < ths.length; i++) {
      var headingText = ths[i].innerHTML;
      THarray.push(headingText);
    }
    var styleElm = document.createElement("style"),
      styleSheet;
    document.head.appendChild(styleElm);
    styleSheet = styleElm.sheet;
    for (var i = 0; i < THarray.length; i++) {
      styleSheet.insertRule(
        "#" +
          elmID +
          " td:nth-child(" +
          (i + 1) +
          ')::before {content:"' +
          THarray[i] +
          ': ";}',
        styleSheet.cssRules.length
      );
    }
  } catch (e) {
    console.log("ResponsiveCellHeaders(): " + e);
  }
}
ResponsiveCellHeaders("browsers");

            
          
!
999px
Loading ..................

Console