<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Advanced CSS Design Resources - last-child.com &#187; Span</title>
	<atom:link href="http://www.last-child.com/category/html-elements/span/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.last-child.com</link>
	<description>CSS Toys for Professional Web Developers</description>
	<lastBuildDate>Mon, 19 Dec 2011 18:30:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Debugging aria-label on elements</title>
		<link>http://www.last-child.com/debugging-aria-label/</link>
		<comments>http://www.last-child.com/debugging-aria-label/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 18:30:15 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[ARIA]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Span]]></category>
		<category><![CDATA[aria-label]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.last-child.com/?p=300</guid>
		<description><![CDATA[I recently helped do some testing on the new version Yahoo! Mail for iPads and was stumped by an aria-label not working as expected. It was one of those gotcha moments, when you realize a confusion with a fundamental process. Are you wondering why your aria-label is not being announced? The aria-label attribute is tempting [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.last-child.com/wp-content/uploads/2011/12/forecast-icons.png" alt="Sat, Sun, Mon - Forecast icons" width="89" height="110" class="alignright size-full wp-image-302" />I recently helped do some testing on the new version <a href="http://mail.yahoo.com">Yahoo! Mail</a> for iPads and was stumped by an aria-label not working as expected. It was one of those gotcha moments, when you realize a confusion with a fundamental process. Are you wondering why your aria-label is not being announced?</p>
<p>The aria-label attribute is tempting to use in situations where the visible text is not adequate.  For instance, you may use a background image to represent a value and you&#8217;d like the user to know that value via an aria-label on the parent. </p>
<p>This basic test page will walk through the simple assumption and show how the aria-label is meant to be used.</p>
<h3>Base configuration</h3>
<ul>
<li><a href="/" aria-label="this basic link has an aria label attribute" >basic link</a><br />
<code>&lt;a href=&quot;/&quot; aria-label=&quot;this basic link has an aria label attribute&quot; &gt;basic link&lt;/a&gt;</code></li>
<li><span aria-label="this basic span has an aria label attribute">basic span</span><br />
<code>&lt;span aria-label=&quot;this basic span has an aria label attribute&quot;&gt;basic span&lt;/span&gt;</code></li>
<li><b aria-label="this basic b has an aria label attribute">basic bold</b><br />
<code>&lt;b aria-label=&quot;this basic b has an aria label attribute&quot;&gt;basic bold&lt;/b&gt;</code></li>
</ul>
<h4>Give &lt;span&gt; and &lt;b&gt; tabindex=&quot;0&quot; to place into tab flow</h4>
<p>Span and b tags are not in the native tab flow. I added tabindex=&quot;0&quot; to see if that was the problem. Now that we can give them focus, the aria-label is still ignored.</p>
<ul>
<li><span aria-label="this basic span has an aria label attribute" tabindex="0">basic span</span><br />
<code>&lt;span aria-label=&quot;this basic span has an aria label attribute&quot; tabindex=&quot;0&quot;&gt;basic span&lt;/span&gt;</code></li>
<li><b aria-label="this basic b has an aria label attribute" tabindex="0">basic bold</b><br />
<code>&lt;b aria-label=&quot;this basic b has an aria label attribute&quot; tabindex=&quot;0&quot;&gt;basic bold&lt;/b&gt;</code></li>
</ul>
<h3>What&#8217;s going wrong</h3>
<p><a href="http://yaccessibilityblog.com/library/tag/aria">ARIA</a> is a tool to make our web sites more accessible. It&#8217;s meant to restore semantic structure and act as a bridge between dynamic web sites and assistive technology. ARIA roles, states, and values allow the web developer to give directions to assistive technology to explain how an element should be treated. This is especially true when the element is expected to work in a non-standard method. For instance, <a href="http://yaccessibilityblog.com/library/aria-fix-non-standard-images.html">Flickr uses divs with background images</a> as images to improve animation on mobile devices.</p>
<p>The aria-label attribute allows us to place a label on these elements that have been re-purposed via JavaScript. It&#8217;s not meant to replace the title attribute on generic tags. </p>
<h3>Convert elements with aria</h3>
<p>The following elements now have ARIA roles: button, img, and slider. These ARIA roles announce the new purpose of these elements. Their aria-label attributes are announced, as they are adding information to these faux-elements. </p>
<ul>
<li><a href="/" aria-label="this link is now a button" role="button">basic link</a><br />
<code>&lt;a href=&quot;/&quot; aria-label=&quot;this link is now a button&quot; role=&quot;button&quot;&gt;basic link&lt;/a&gt;</code></li>
<li><span aria-label="this span is now treated as an image." role="img" class="fakeimg" tabindex="0">basic span</span><br />
<code>&lt;span aria-label=&quot;this span is now treated as an image.&quot; role=&quot;img&quot; class=&quot;fakeimg&quot; tabindex=&quot;0&quot;&gt;basic span&lt;/span&gt;</code></li>
<li><b aria-label="this b is now treated as a slider" role="radio" tabindex="0">basic bold</b><br />
<code>&lt;b aria-label=&quot;this b is now treated as a radio button&quot; role=&quot;radio&quot; tabindex=&quot;0&quot;&gt;basic bold&lt;/b&gt;</code></li>
</ul>
<h3>Back to the original problem</h3>
<p><img src="http://www.last-child.com/wp-content/uploads/2011/12/forecast-icons.png" alt="Sat, Sun, Mon - Forecast icons" width="89" height="110" class="alignright size-full wp-image-302" /> In the forecast example, the original idea was to put aria-label on the span that included the text &#8220;Sat&#8221;, &#8220;Sun&#8221;, or &#8220;Mon&#8221;. The aria-label described the weather illustrated in the icon. After realizing this was not working, we realized it was being over-thought. The icons were background images, we just needed to add the desired text to the background image container. </p>
<p>ARIA is a great way to solve problems. However, it wasn&#8217;t meant to replace basic HTML.  Here&#8217;s a proposed solution sans ARIA:</p>
<pre>
<code>
&lt;th scope="row" title=&quot;Saturday&quot;&gt;Sat&lt;/th&gt;
&lt;td class=&quot;cloudy&quot;&gt;&lt;span class=&quot;visuallyhidden&quot;&gt;Cloudy&lt;/span&gt;&lt;/td&gt;
</code>
</pre>
<h3>Resources</h3>
<ul>
<li><a href="http://www.w3.org/TR/wai-aria/roles#textalternativecomputation">ARIA Text Alternative Computation</a></li>
<li><a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-label">Spec for aria-label</a></li>
<li><a href="http://yaccessibilityblog.com/library/css-clip-hidden-content.html" >Clip your hidden content for better accessibility</a></li>
<li><a href="http://yaccessibilityblog.com/library/dynamic-form-labels-aria.html">Create Dynamic Form Labels with ARIA</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/debugging-aria-label/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image sprites &#8211; flexible and accessible packages</title>
		<link>http://www.last-child.com/image-sprites-flexible-and-accessible-packages/</link>
		<comments>http://www.last-child.com/image-sprites-flexible-and-accessible-packages/#comments</comments>
		<pubDate>Tue, 17 Oct 2006 20:11:11 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Definition List]]></category>
		<category><![CDATA[HTML Elements]]></category>
		<category><![CDATA[Image Replacement]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[Span]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://www.last-child.com/image-sprites-flexible-and-accessible-packages/</guid>
		<description><![CDATA[User generated ratings and reviews are an important part of all Yahoo! sites. You can find them on just about every page of Yahoo! Tech.&#160; It was important for us to develop a ratings presentation device that was easy to code, accessible, flexible, and as light-weight as possible. Our final design uses a combination of [...]]]></description>
			<content:encoded><![CDATA[<p> User  generated ratings and reviews are an important part of all Yahoo! sites. You can find them on  just about every page of <a href="http://tech.yahoo.com">Yahoo! Tech</a>.&nbsp; It  was important for us to develop a ratings presentation device that was easy to code,  accessible, flexible, and as light-weight as possible. Our final design  uses a combination of image sprites and negative text-indent to satisfy these requirements.</p>
<p>
Product ratings are represented with 1 to 5 stars. Other sites  have used inline images; repeating a solid or empty version for each of the  five stars. <img src="http://us.i1.yimg.com/us.yimg.com/i/us/sh/karma/ar_star_4half.gif" alt="stars image from Yahoo! Shopping" width="93" height="16" />Other sites, such as Yahoo! Shopping, have used a single inline image representing the number of  stars.&nbsp;  At best, the image will have an alt attribute that descibes the number of stars. However, the content is locked inside the image. This is an easy approach for  coding but isn&rsquo;t the most accessible approach. </p>
<h3>Yahoo! Tech uses the <strong>content first</strong> approach to design</h3>
<p>
Content-first design improves accessibility. This approach places the relevant content in semantic markup. It then uses CSS to transform that content into the visual design. Here is a sample rating from Yahoo! Tech: <strong>Overall:4/5, Quality:5/5, Support: 3/5</strong>. Our CSS transform that simple text into a series of stars and accompanying text. User testing with a screen-reader user led us to remove visual descriptions from the content, i.e.&quot;stars&quot; or &quot;bars&quot;. </p>
<h3>With the content in the page, it was time to look at the visual design. </h3>
<p>Ratings are presented in either an unordered list or definition list. We need to place descriptive text in front of the stars and want the stars to be aligned with each other. These considerations lead to using spans with a combination of CSS rules to hide the text, insert a background image, and absolutely position the ratings to the right side of the list item.  <strong>Let&rsquo;s look at the code.</strong></p>
<h4>The HTML &#8211; span </h4>
<p>
To use  a background image for the stars, we  need a container that can be manipulated with CSS and not include presentational behaviors  of its own. This is why we  use the span, a generic inline container.  We could  use a strong or em, but feel the span offers the best  versatility. You never know when the graphic designer will ask for some text to be bolded or emphasized in the same list item. </p>
<h4>Sample code for a rating</h4>
<p><code lang="HTML"></p>
<ul class="ratingslist">
<li class="stars4">Overall: <span title="Yahoo! users gave the Apple iPod 4 out of 5 stars for Overall Quality">4/5</span></li>
</ul>
<p></code></p>
<p>
The span&rsquo;s title will generate a tooltip when the user places their mouse over the rating (not Internet Explorer). Screen readers&#8217; default settings ignore title attributes on non-form items.</p>
<h4>The CSS</h4>
<p>
Spans are inline elements.&nbsp;  To display background images, we need to make them display block, define  a height, width, and move the text off the screen. To keep them inline with the  text, we are also positioning them absolutely. We could  position them relatively or floated the spans. Position absolute works the best for our pages.The parent list item is positioned  relatively to give the span a contextual anchor. Negative text-indent will hide the rating text.</p>
<p><code lang="CSS"><br />
.ratingslist {list-style-type:none;}<br />
.ratingslist li {position:relative;  padding:3px 5px; }<br />
.ratingslist li span {text-indent:-1000em; width:66px;  display:block; position:absolute;  top:5px; right:20px;}<br />
</code></p>
<h4>Image sprites display the desired number of stars</h4>
<p>
The list item is given a class with a number at the end  (stars8). This will display an image with four out of five red stars. We are using a scale of 0 to 10 to accomodate half stars. To  display other rating variations, we change the modifier, i.e. prostars4,  retstars4, bars4, bigstars4, etc&hellip;</p>
<p>
To simplify the maintenance of the site and  reduce server  requests; Yahoo! Tech also uses image sprites. Sprites are <a href="http://l.yimg.com/tech.yahoo.com/images/20061004202215/bg-ratings.png">single images that include multiple icons</a> with a consistent spacing between them. Use background positioning to display the desired chunk of the image. Each sprite represents the  possible color variations used on the site: red, blue, and green. Minimizing the  color palettes reduces the final image size.  For more  information on sprites, read <a href="http://www.alistapart.com/articles/sprites/">CSS Sprites: Image Slicing&rsquo;s Kiss of Death</a> by Dave Shea. As a further enhancement, alpha transparent png images are  used for most browsers and index-transparent gifs are presented in the Internet  Explorer 6  style sheets.&nbsp;</p>
<p>
Background images are positioned with the set of numbers after &quot;no repeat.&quot; The horizontal positioning is first. Our sprite is vertical, so we are leaving it alone, hence the 0 value. The vertical positiong comes next. If we want to display 2 out of 5 stars, we need to shift the background down to that part of the image (-530px). Here is the CSS for presenting the specific star variant.</p>
<p><code lang="CSS"><br />
/* Ratings images<br />
  ======================================= */<br />
  .stars0 span {background:url(/images/bg-ratings.png)  no-repeat 0 -650px;}<br />
  .stars1 span {background:url(/images/bg-ratings.png)  no-repeat 0 -620px;}<br />
  .stars2 span {background:url(/images/bg-ratings.png)  no-repeat 0 -590px;}<br />
  .stars3 span {background:url(/images/bg-ratings.png)  no-repeat 0 -560px;}<br />
  .stars4 span {background:url(/images/bg-ratings.png)  no-repeat 0 -530px;}<br />
  .stars5 span {background:url(/images/bg-ratings.png)  no-repeat 0 -500px;}<br />
  &hellip; (repeated for each variation of the stars and bars)<br />
</code></p>
<p>
This approach has allowed the Yahoo! Tech engineers  to maintain a consistent presentation  with minimal  markup. For pages that need special tweaks we can easily adjust the positioning  by using descending selectors: </p>
<p><code lang="CSS"><br />
#mytech .ratingslist li span { right:5px;}<br />
</code></p>
<h4>Caveats</h4>
<p>
We&rsquo;ve only found a few small issues with this approach. </p>
<ul >
<li>You cannot count on background images being displayed on the printed page. Our print style sheet removes the text-indent and background images to display &ldquo;Overall: 4/5&rdquo;. </li>
<li>When       someone includes more than 4 products in the comparison table, the text of some rating parameters will begin to overlap the stars. If they were inline images or if we floated the spans, they may drop to the next line. </li>
</ul>
<p>
Yahoo Tech! ratings are another example of creating  accessible and visually dynamic pages by considering the underlying content  structure before attacking the styles. Users of all abilities are presented  with solid information. That&rsquo;s how you can deliver a 5 star page every time.</p>
<p>Related Information</p>
<ul>
<li> <a href="http://www.alistapart.com/articles/sprites/">CSS Sprites: Image Slicing&rsquo;s Kiss of Death</a> by Dave Shea.</li>
<li><a href="/make-flash-accessible-to-screen-readers-in-transparent-window-mode/">Making Flash Accessible to Screen Readers</a></li>
<li><a href="http://rollyo.com/search.html?q=sprites&#038;uid=0&#038;sid=4886">Standardista Search: Sprites</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/image-sprites-flexible-and-accessible-packages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Is it ok to use span?</title>
		<link>http://www.last-child.com/is-it-ok-to-use-span/</link>
		<comments>http://www.last-child.com/is-it-ok-to-use-span/#comments</comments>
		<pubDate>Mon, 22 May 2006 14:37:19 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML Elements]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Span]]></category>

		<guid isPermaLink="false">http://www.last-child.com/is-it-ok-to-use-span/</guid>
		<description><![CDATA[The &#60;span> tag is often avoided by developers at all costs. It carries no semantic or presentational value and exisits solely as a container and hook for a developer&#8217;s CSS. Many argue that more semantic options, i.e. &#60;strong> or &#60;em> should be used instead. This is a good argument, but never say never. Think about [...]]]></description>
			<content:encoded><![CDATA[<p>The &lt;span> tag is often avoided by developers at all costs. It carries no semantic or presentational value and exisits solely as a container and hook for a developer&#8217;s CSS. Many argue that more semantic options, i.e. &lt;strong> or &lt;em> should be used instead. This is a good argument, but never say never. </p>
<p>Think about how important the information is inside a span that will use CSS to add image replacement, sliding doors, warning notices, etc&#8230; If the information should be emphasized, use something else.  If the content is not more important than the text around it, a span is a better choice.  <a href="http://www.meyerweb.com/eric/thoughts/2004/08/23/markup-missive/">Eric Meyer<del title="oopsy, where did that s come from?">s</del></a> prefers to use the non-semantic &lt;b> tag, which adds style but no semantic weight. This is also an option. <a href="http://lachy.id.au/log/">Lachlan Hunt</a> has created an essay that describes the <a href="http://lachy.id.au/log/2005/01/semantics-of.html">Semantics of &lt;span></a> and his disagreement with Meyers. </p>
<blockquote cite="http://lachy.id.au/log/2005/01/semantics-of.html"><p>
While, in Eric’s case, the use of the extraneous element, be it span or b, was entirely presentational since the semantics of the content is being expressed by the parent element, not the element itself; there may be many cases where it is considered useful to revert to these other, often disregarded, presentational elements to assist with conveying semantics to some readers, usually in a visual medium, where no other semantic element is appropriate. However, for a similar reason, authors must be careful because the elements may convey semantics that they do not have (eg. &lt;b> may, depending on the context, inadvertently convey a form of strong emphasis in a visual medium). Therefore, although some presentational elements are not deprecated, I do not recommend these presentational elements be used often, and that you carefully weigh up your other options before doing so.<br />
<cite><a href="http://lachy.id.au/log/2005/01/semantics-of.html">Lachy&#8217;s Log</a></cite></p></blockquote>
<p>The span is not a tag to dismiss. It is a flexible container; suitable for content that you want to add styles, <a href="http://www.microformats.org">microformats</a>, or metadata without having the content become more important than the sibling text. Use more semantic alternatives when the content should stand out to a screenreader or with CSS disabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/is-it-ok-to-use-span/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

