cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <h1>Content Group</h1>
<p>How to wrap an image, link, and text as one large touch target, while using progressively enhanced, valid HTML and keeping things fully accessible.</p>

<article class="article-teaser js-content-group" data-url="http://google.com" data-title="Google">  
  <img src="http://placehold.it/200x150" width="200" height="150" alt=""/>  
  <h2>
    <a href="http://google.com">Google</a>
  </h2>  
  <p>Search the internet for things.</p>  
</article>

<article class="article-teaser js-content-group" data-url="http://apple.com" data-title="Apple">  
  <img src="http://placehold.it/200x150" width="200" height="150" alt=""/>  
  <h2>
    <a href="http://apple.com">Apple</a>
  </h2>  
  <p>This one points to the Apple homepage.</p>  
</article>

<article class="article-teaser js-content-group" data-url="http://a11yproject.com" data-title="A11Y Project">  
  <img src="http://placehold.it/200x150" width="200" height="150" alt=""/>  
  <h2>
    <a href="http://a11yproject.com">A11YProject</a>
  </h2>  
  <p>One more for testing purposes.</p>  
</article>

<ul>
  <li>The idea behind this is to minimize the amount of tab presses required by keyboard users to navigate through content.</li>
  <li>Inspired after watching this video from Nomensa: <a href="http://www.nomensa.com/blog/2014/tips-on-combining-image-and-text-links/">Tips on combining image and text links</a>.</li>
  <li>This concept is also a <a href="http://www.w3.org/TR/2014/NOTE-WCAG20-TECHS-20140311/H2">WCAG 2.0 technique requirement</a>.</li>
  <li>Tested with NVDA+Firefox, ChromeVox, and VoiceOver+Chrome.</li>
  <li><a href="http://codepen.io/svinkle/pen/GfumK">jQuery version</a>.</li>
</ul>
            
          
!
            
              body {
  margin: 1em;
} 

a {
  color: DodgerBlue;
  text-decoration: none;
}

.article-teaser {
  border: solid Gray 1px;
  display: inline-block;
  margin: 0 1em 1em 0;
  max-width: 12em;
}

a:active,
a:focus,
a:hover {
  background-color: DodgerBlue;
  color: White;
}

.article-teaser img {
  height: auto;
  max-width: 100%;
}
  
.article-teaser h2 {
  padding: 0 .5em;
}
  
.article-teaser p {
  padding: 0 1em;
}

.clickable {
  cursor: pointer;
}
            
          
!
            
              (function (document, window, undefined) {
  'use strict';
  
  // Vars
  var contentGroup = document.querySelectorAll('.js-content-group');
  
  // For each
  [].forEach.call(contentGroup, function(group, index) {
    // Vars
    var link = group.querySelector('a'),
        title = group.querySelector('h2'),
        text = group.querySelector('p');
    
    // Set attributes
    link.setAttribute('tabindex', '-1');    
    title.setAttribute('id', 'group-title-' + index);    
    text.setAttribute('id', 'group-text-' + index);
    text.setAttribute('aria-hidden', 'true');
    
    // Group "button" attibutes
    group.classList.add('clickable');
    group.setAttribute('tabindex', '0');
    group.setAttribute('role', 'link');
    group.setAttribute('aria-labelledby', 'group-title-' + index);
    group.setAttribute('aria-describedby', 'group-text-' + index);
    
    // Click event
    group.addEventListener('click', function () {
      window.location.href = this.getAttribute('data-url');      
    }, false);
    
    // Keydown event
    group.addEventListener('keydown', function (event) {
      if (event.which === 13) {
        event.preventDefault();
        window.location.href = this.getAttribute('data-url');      
      }
    }, false);
  });
    
})(document, window);
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console