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

              
                <h1>Images from CSS Generated Content with Text Alternatives</h1>

<div>
  <div>

    <h2>Valid References</h2>

    <p>
      <a href="https://www.nasa.gov/" class="goodRef">NASA</a>
    </p>

    <h3 class="goodRef">Heading Level 3</h3>

    <p class="goodRef">
      Plain text on the page.
    </p>

    <button class="goodRef">Button</button>

    <p>
      <label for="T1" class="goodRef">Field Label</label><br>
      <input type="text" id="T1">
    </p>

    <p class="goodRef">
      Emoji as the alternative
    </p>

  </div>
  <div>

    <h2>Broken References</h2>

    <p>
      <a href="https://www.nasa.gov/" class="badRef">NASA</a>
    </p>

    <h3 class="badRef">Heading Level 3</h3>

    <p class="badRef">
      Plain text on the page.
    </p>

    <button class="badRef">Button</button>

    <p>
      <label for="T2" class="badRef">Field Label</label><br>
      <input type="text" id="T2">
    </p>

    <p class="badRef">
      Emoji as the alternative
    </p>

  </div>
  <div>

    <h2>With <code>data-alt</code> Attribute</h2>

    <p>
      <a href="https://www.nasa.gov/" class="altRef" data-alt="arrow">NASA</a>
    </p>

    <h3 class="altRef" data-alt="arrow">Heading Level 3</h3>

    <p class="altRef" data-alt="arrow">
      Plain text on the page.
    </p>

    <button class="altRef" data-alt="arrow">Button</button>

    <p>
      <label for="T5" class="altRef" data-alt="arrow">Field Label</label><br>
      <input type="text" id="T5">
    </p>

    <p class="altRef" data-alt="🏹">
      Emoji as the alternative
    </p>

  </div>
  <div>

    <h2>Image Instead</h2>

    <p>
      <a href="https://www.nasa.gov/"><img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="Rubbish"> NASA</a>
    </p>

    <h3><img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="Rubbish"> Heading Level 3</h3>

    <p>
      <img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="Rubbish"> Plain text on the page.
    </p>

    <button><img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="Rubbish"> Button</button>

    <p>
      <label for="T3"><img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="Rubbish"> Field Label</label><br>
      <input type="text" id="T3">
    </p>

    <p>
      <img src="https://assets.codepen.io/2729/icon_trash_red.svg" alt="🚮"> Emoji as the alternative
    </p>
    
  </div>
  <div>

    <h2>Broken Image</h2>

    <p>
      <a href="https://www.nasa.gov/"><img src="https://example.com/foo.gif" alt="Bear"> NASA</a>
    </p>

    <h3><img src="https://example.com/foo.gif" alt="Bear"> Heading Level 3</h3>

    <p>
      <img src="https://example.com/foo.gif" alt="Bear"> Plain text on the page.
    </p>

    <button><img src="https://example.com/foo.gif" alt="Bear"> Button</button>

    <p>
      <label for="T4"><img src="https://example.com/foo.gif" alt="Bear"> Field Label</label><br>
      <input type="text" id="T4">
    </p>

    <p>
      <img src="https://example.com/foo.gif" alt="🐼"> Emoji as the alternative
    </p>

  </div>
</div>


<!--
macOS 10.15.6 Catalina

Safari 14
 presence of / alt invalidates entire rule, so no image appears
 missing image will only show alt in the space reserved for the image, no overflow; reads alt text even if broken image
Chome 85
 fine; reads alt text even if broken image
 shows broken image icon (does not reserve space) _and_ alt text alongside it
Firefox 81
 presence of / alt invalidates entire rule, so no image appears
 missing image does not display the alt text, unless it is an emoji; reads alt text even if broken image

Windows 10

Chrome 85
 fine; reads alt text even if broken image
 shows broken image icon (does not reserve space) _and_ alt text alongside it
Firefox 81
 presence of / alt invalidates entire rule, so no image appears
 missing image displays alt text, no broken image indicator
IE11
 presence of / alt invalidates entire rule, so no image appears
 missing image will only show alt in the space reserved for the image, no overflow; reads alt text even if broken image

iOS 14

Safari
 presence of / alt invalidates entire rule, so no image appears
 missing image will only show alt in the space reserved for the image, no overflow; reads alt text even if broken image (SVGs were not read except in link, button)

Android 11

Firefox 81
 presence of / alt invalidates entire rule, so no image appears
 missing image displays alt text, no broken image indicator; emoji alt not announced at all
Chrome 85
 fine; reads alt text even if broken image
 shows broken image icon (does not reserve space) _and_ alt text alongside it; emoji alt not announced at all
-->
              
            
!

CSS

              
                body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.4;
  /*   line-height: 1.5; */
  /*   letter-spacing: 0.12em; */
  /*   word-spacing: 0.16em; */
}

.goodRef::before, .altRef::before, .badRed::before {
  display: inline-block;
  height: 1em;
  width: 1em;
  padding-right: .25em;
}

.goodRef::before {
  content: url(https://assets.codepen.io/2729/icon_trash_red.svg) / " trash ";
}

p:last-child.goodRef::before {
    content: url(https://assets.codepen.io/2729/icon_trash_red.svg) / " 🚮 ";
}

.altRef::before {
  content: url(https://assets.codepen.io/2729/mega-nav-arrow-optimized.svg) / attr("data-alt");
}

.badRef::before {
  content: url("https://example.com/foo.gif") / " panda "
}

p:last-child.badRef::before {
    content: url() / " 🐼 ";
}

img {
  width: 1em;
  height: auto;
}


h1 + div {
  display: flex;
  flex-wrap: wrap;
}

h1 + div > div {
  margin: 0 .5em;
  flex: 1 1 16em;
}

input[type=text] {
  width: 9em;
}
              
            
!

JS

              
                
              
            
!
999px

Console