<?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; Image Sprites</title>
	<atom:link href="http://www.last-child.com/category/css/image-sprites/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>Adding style to your rel attributes with CSS</title>
		<link>http://www.last-child.com/rel-attribute-display/</link>
		<comments>http://www.last-child.com/rel-attribute-display/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:03:00 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[attribute selector]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS2]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[microformats]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Data Formats]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[rel]]></category>
		<category><![CDATA[xfn]]></category>

		<guid isPermaLink="false">http://www.last-child.com/?p=153</guid>
		<description><![CDATA[View the finished example: Adding style to your rel link. There&#8217;s a little attribute in HTML links that is starting to get a bit of attention lately. The &#8220;rel&#8221; attribute is a sparsely defined attribute that applies some meta information about a link&#8217;s relationship to other documents. Unfortunately, this information is usually hidden from your [...]]]></description>
			<content:encoded><![CDATA[<p>View the finished example: <a href="/examples/rel-attribute/index.html">Adding style to your rel link</a>.</p>
<p>There&#8217;s a little attribute in HTML links that is starting to get a bit of attention lately. The &#8220;rel&#8221; attribute is a <a href="http://www.w3.org/TR/REC-html40/types.html#type-links">sparsely defined attribute</a> that applies some meta information about a link&#8217;s relationship to other documents. Unfortunately, this information is usually hidden from your users. Let&#8217;s take a light-hearted stab at turning it into a visual element.</p>
<h3>Rel attribute usage</h3>
<p>
While the W3C originally considered the rel attribute to describe the relationship of pages to each other, i.e. next, previous, directory, and start. The attribute has been adopted by the <a href="http://microformats.org">Microformat</a> community for its inherit usefulness. The rel attribute is now used for <a href="http://microformats.org/wiki/rel-tag">tags</a>, <a href="http://gmpg.org/xfn/">to define your relationship to someone</a>, and even to <a href="http://microformats.org/wiki/rel-nofollow">tell search engines not to bother following a link</a>. </p>
<p>
The opportunities to use the rel attribute are seemingly endless. There are more proposals to <a href="http://xen.adactio.com/">define people you don&#8217;t like</a> and <a href="http://microformats.org/wiki/vote-links">links for voting</a>.  </p>
<p>
But all of this flexibility comes at a small price. To remain valid, you need to tell the browser what these new rel values may actually mean. This is handled by <a href="http://microformats.org/wiki/profile-uris">linking to appropriate profiles</a>. Just simply insert the profiles into your head tag. <a href="http://microformats.org/wiki/profile-uris#Combined_Profile">Multiple profiles</a> may throw a validation error, but it&#8217;s ok.  You don&#8217;t need to do this for the standard rel values.</p>
<p><code lang="HTML"><br />
<head profile="http://www.ietf.org/rfc/rfc2731.txt http://www.w3.org/2006/03/hcard"><br />
</code></p>
<p>
We will be using the CSS3 attribute selector functionality to look at the value of the rel attribute and apply some style accordingly. First we&#8217;ll add some padding and a background image to any link that has a rel attribute. We&#8217;ll then use background positioning to display an icon that is appropriate for the link. It&#8217;s a fairly simple hack. </p>
<p>For more information on using attribute selectors, check out my previous posts: </p>
<ul>
<li><a href="/css-attribute-selector/">Progressive enhancement of links using the CSS attribute selector</a></li>
<li><a href="/attribute-selectors-to-provide-language-information/">Attribute selectors to provide language information</a></li>
</ul>
<h3>Sample HTML Code</h3>
<p><code lang="HTML"></p>
<li><a href="http://microformats.org/wiki/rel-nofollow" rel="no-follow">This link is ignored by search engines</a> (rel="no-follow")</li>
<li><a href="http://microformats.org/wiki/rel-tag" rel="tag">A sample tag </a> (rel="tag")</li>
<p></code></p>
<h3>Sample CSS </h3>
<p><code lang="CSS"><br />
a[rel] {padding-left:20px; background:url(rel-sprite.png) no-repeat 0 0; }<br />
a[rel~="help"] {background-position: 0 -350px ;}<br />
a[rel~="license"] {background-position: 0 -1347px ;}<br />
a[rel~="no-follow"] {background-position: 0 -1200px ;}<br />
a[rel~="tag"] {background-position: 0 -47px ;}<br />
</code></p>
<h3>It&#8217;s all fun and games</h3>
<p>
I&#8217;ll be the first to admit this exercise has significant issues. I&#8217;m assuming the following elements are true:</p>
<ol>
<li>All possible rel attribute values are accounted for in my CSS, if not there will be a blank space generated by the first rule</li>
<li>You can only have one relationship defined by XFN. Unfortunately, most people are defined by multiple values, i.e. rel=&#8221;met friend colleague&#8221;. This CSS does not account for multiple values. </li>
</ol>
<p>So, the display of your rel attributes may be a bit off in the edge cases. Keep the spirit light and nobody will say anything&#8230; I hope. Have fun with your rel attributes. They&#8217;re just sitting there waiting to be used. </p>
<p><a href="/examples/rel-attribute/index.html">View the finished rel attribute style example</a>.</p>
<h3>Related Information</h3>
<ul>
<li>Microformats Wiki: <a href="http://microformats.org/wiki/profile-uris#Combined_Profile">Profile URI&#8217;s</a></li>
<li>Microformat: <a href="http://microformats.org/wiki/rel-design-pattern">Rel Design Pattern</a></li>
<li>Microformat: <a href="http://microformats.org/wiki/rel-tag">Tags</a></li>
<li>Microformat: <a href="http://microformats.org/wiki/rel-no-follow">No Follow</a></li>
<li>Microformat: <a href="http://microformats.org/wiki/rel-bookmark">Bookmark</a></li>
<li>Microformat: <a href="http://gmpg.org/xfn/">XFN &#8211; Friends Network</a></li>
<li>Microformat: <a href="http://xen.adactio.com/">XEN &#8211; Enemies Network</a></li>
<li>W3C: <a href="http://www.w3.org/TR/REC-html40/types.html#type-links">Link Types</a></li>
<li><a href="http://www.iconbuffet.com/">Icon Buffet</a> &#8211; The source of most icons used in this example</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/rel-attribute-display/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Progressive enhancement of links using the CSS attribute selector</title>
		<link>http://www.last-child.com/css-attribute-selector/</link>
		<comments>http://www.last-child.com/css-attribute-selector/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 20:13:00 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[:after]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[attribute selector]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS2]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[min-height]]></category>
		<category><![CDATA[Online Resource]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.last-child.com/?p=152</guid>
		<description><![CDATA[Attribute Selector Test Page We have avoided using CSS3 rules for too long. It&#8217;s been difficult to justify using rules that won&#8217;t work for a significant portion of our audience, Internet Explorer 7 and below. However, Internet Explorer 8 is coming out soon and does work with the features we like. I think it&#8217;s fairly [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/examples/attrib-files/index.html">Attribute Selector Test Page </a></p>
<p>
We have avoided using CSS3 rules for too long. It&#8217;s been difficult to justify using rules that won&#8217;t work for a significant portion of our audience, Internet Explorer 7 and below.  However, Internet Explorer 8 is coming out soon and does work with the features we like. </p>
<p>
 I think it&#8217;s fairly safe to assume IE7 users will upgrade to IE8 within a short time. Those stuck with IE6 for one reason or another will slowly disappear as they are given new computers or their locked down environments are upgraded.</p>
<p>
So, with the future of CSS3 functionality within reach, I&#8217;ve been energized to begin experimenting again.  I&#8217;ll be writing a series of blog posts over the next few months that look at CSS3 functionality as a progressive enhancement. How can we continue to deliver a perfectly fine web site to IE6 and IE7 and mobile phones while enhancing the functionality of more modern browsers and devices?</p>
<h3>Attribute Selectors</h3>
<p>
CSS attribute selectors are the golden ring on the web development merry-go-round. They can be daunting to learn, addictive to use, but then disappointing when you realize they are out of your grasp when you test in Internet Explorer.  We can, however, begin using them to add additional functionality based on your pre-existing, semantic code. Attribute selectors give you power to write CSS that pinpoints the stuff you already code, without having to go back and add classes or ids. I&#8217;ve written previously about <a href="/attribute-selectors-to-provide-language-information/">using attribute selectors to let your users know the language of a site they are about to visit</a>. This trick relies on the rarely used hreflang attribute, which identifies the language of the site targeted in a link.</p>
<p>
There are many other attributes in your HTML, from <a href="http://www.w3.org/TR/html4/struct/tables.html#h-11.4.1">table headers</a>, <a href="http://www.w3.org/TR/REC-html40/struct/objects.html#adef-src-IMG">image src</a>,  <a href="http://www.w3.org/TR/html401/struct/links.html#h-12.1.4">link titles</a>, and <a href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.6.1">selected options</a>. Think about all of those juicy attributes just waiting to be targeted. Also think about how you could actually do something useful with them.</p>
<h3>Announce the file type of a link with CSS</h3>
<p>
I once worked for a company that had hundreds of thousands of static HTML pages in their intranet. With no content management system; it was impossible to make global changes. The only thing they shared was a common set of style sheets. Does this sound familiar?  Follow along as we increase your site&#8217;s usability in a less than perfect, but efficient way. </p>
<p>
First off, for accessibility, you need to let users know when a link  will open a file, what type it is, and how large it is. This is best done by adding it to your HTML code:</p>
<p><code lang="HTML"><br />
<a href="foo.pdf" class="pdf">Foo presentation (.pdf, 5kb)</a><br />
</code></p>
<p>That delivers the information to everyone, regardless of their browser.  This, however takes time and is a daunting task for updating legacy code. </p>
<p>
We can, however, use the <a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#attribute-selectors">atttribute selector</a> to target the extension of the link to display the icon and insert the text describing the file type. Here&#8217;s the sample HTML code:</p>
<p><code lang="HTML"></p>
<ul>
<li><a href="foo.zip" >sample zip link</a></li>
<li><a href="foo.pdf" >sample pdf link</a></li>
<li><a href="foo.doc" >sample Word link</a></li>
<li><a href="foo.exe" >sample Executable link</a></li>
<li><a href="foo.png" >sample png image</a></li>
<li><a href="foo.mp3" >sample MP3 file </a></li>
</ul>
<p></code><br />
It&#8217;s a simple list of links for different types of files. We&#8217;ll be looking at the extensions: .zip, .pdf, .doc, .exe, .png, and .mp3. Feel free to extend this list to any extension you so desire. This would be especially helpful for a company that uses proprietary file types within their intranet.</p>
<p>
Now, let&#8217;s look at the CSS:</p>
<p><code lang="CSS"><br />
a[href$="zip"],<br />
a[href$="pdf"],<br />
a[href$="doc"],<br />
a[href$="exe"],<br />
a[href$="png"],<br />
a[href$="mp3"]  {padding-left:20px; background:url(bg-file-icons.png) no-repeat 0 0;}<br />
a[href$="png"]{background-position: 0 -48px;}<br />
a[href$="pdf"] {background-position: 0 -99px;}<br />
a[href$="mp3"]{background-position: 0 -145px;}<br />
a[href$="doc"]{background-position: 0 -199px;}<br />
a[href$="exe"]{background-position: 0 -250px;}</p>
<p>a[href$=".zip"]:after{content: "(.zip file)"; color:#999; margin-left:5px;}<br />
a[href$=".pdf"]:after{content: "(.pdf file)"; color:#999; margin-left:5px;}<br />
a[href$=".doc"]:after{content: "(.doc file)"; color:#999; margin-left:5px;}<br />
a[href$=".exe"]:after{content: "(.exe file)"; color:#999; margin-left:5px;}<br />
a[href$=".mp3"]:after{content: "(.mp3 file)"; color:#999; margin-left:5px;}<br />
a[href$=".png"]:after{content: "(.png file)"; color:#999; margin-left:5px;}<br />
a[href$=".exe"]:after{content: "(.exe file)"; color:#999; margin-left:5px;}<br />
</code></p>
<p><a href="/examples/attrib-files/index.html">See the final test page.</a></p>
<h4>Pattern matching in the attribute selector</h4>
<p>We have some limited &#8220;regular expression&#8221; functionality in CSS3. We can search for an attribute&#8217;s presence and match a pattern within the attribute&#8217;s value.<br />
<a href="http://www.hunlock.com/">Patrick Hunlon</a> has a good summary of the pattern matching: </p>
<blockquote cite="http://www.hunlock.com/blogs/Attach_icons_to_anything_with_CSS">
<ul>
<li>[foo]        &#8212; Has an attribute named &#8220;foo&#8221;</li>
<li>[foo="bar"]  &#8212; Has an attribute named &#8220;foo&#8221; with a value of &#8220;bar&#8221; (&#8220;bar&#8221;)</li>
<li>[foo~="bar"] &#8212; Value has the word &#8220;bar&#8221; in it somewhere (&#8220;blue bar stools&#8221;)</li>
<li>[foo^="bar"] &#8212; Value begins with &#8220;bar&#8221; (&#8220;barstool&#8221;)</li>
<li>[foo$="bar"] &#8212; Value ends with &#8220;bar&#8221; (&#8220;I was at the bar&#8221;)</li>
<li>[foo*="bar"] &#8212; Value has bar somewhere (&#8220;I was looking for barstools&#8221;)  </li>
</ul>
<p><cite><a href="http://www.hunlock.com/blogs/Attach_icons_to_anything_with_CSS">Attach icons to anything with CSS</a></cite>
</p></blockquote>
<p>
The CSS is simply looking to see if the desired extension is at the end of the link href. If so, apply the following styles. </p>
<h4>Adding an icon to the link</h4>
<p>First, we are match any of the desired file extensions.  We then add a background image and some padding on the left side with a bulk rule. Then  the background position on the sprite is adjust for each particular link type. Combining multiple icons into one background image reduces the number of files the user has to download, <a href="http://developer.yahoo.com/performance/rules.html#opt_sprites">making your page faster</a>. This will work with any browser that recognizes attribute selectors, including Internet Explorer 7. However, support for more obscure attributes may be spotty.</p>
<p>
There&#8217;s another peculiarity with pattern matching. Some attributes are case sensitive while others are not. The href attribute is NOT case sensitive, so the above rules will also work if your image name was <em>FOO.ZIP</em>, <em>foo.Zip</em>, or <em>foo.zip</em>.</p>
<h4>Adding the descriptive text</h4>
<p>Now, we are going to add a bit of descriptive text to each link. We can&#8217;t describe the file size, but we can tell the user what type of file it is. This is using the :after(content:) functionality and is supported by Internet Explorer 8 (yeah!!!) but not Internet Explorer 7 and below (boo!!!).<br />
We will also adjust the color and give it a bit of spacing.</p>
<h3>A big step forward with a small chunk of work</h3>
<p>
There you have it. A small chunk of CSS coding has now added substantial usability to your legacy pages. While the CSS version is not as accessible as having the data in the actual link code, it&#8217;s a significant improvement over nothing at all. Further, there&#8217;s no harmful effect on browsers that do not understand the function. You&#8217;ve added information, but haven&#8217;t taken anything away. This is a win in my book. To save some time and effort, you could just download and use this  package of <a href="http://pooliestudios.com/projects/iconize/">CSS and icons</a> from <a href="http://pooliestudios.com">Alexander Kaiser</a>.</p>
<p>
This rather simple example of attribute selectors and pattern matching can open your eyes to many possibilities. There are a number of developers that have been expoloring this potential for the past few years. Take a look at some of these resources for more ideas and have some fun.</p>
<ul>
<li><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#attribute-selectors">CSS3 &#8211; Atribute Selectors Definition </a> W3C</li>
<li><a href="http://www.456bereastreet.com/archive/200601/css_3_selectors_explained/">CSS 3 Selectors Explained</a></li>
<li><a href="http://www.stuffandnonsense.co.uk/archives/css_a_tribute_to_selectors.html">CSS: A Tribute to Selectors</a></li>
<li><a href="http://developer.yahoo.com/yui/selector/">YUI: Selector Utility</a> Use CSS3 selectors in JavaScript</li>
<li><a href="http://www.cssdrive.com/index.php/forums/viewthread/45/">Dynamic File Type Notations </a></li>
<li><a href="http://www.andybudd.com/archives/2003/09/cool_use_for_css_attribute_selectors/">Cool use for CSS attribute selectors </a> &#8211; Hiding banner ads with CSS</li>
<li><a href="http://www.askthecssguy.com/2006/12/showing_hyperlink_cues_with_cs_1.html">Showing Hyperlink Cues with CSS </a></li>
<li><a href="http://www.askthecssguy.com/2006/12/showing_hyperlink_cues_with_cs_1.html">Showing Hyperlink Cues with CSS </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/css-attribute-selector/feed/</wfw:commentRss>
		<slash:comments>5</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>IE7 background sprite bug &#8211; the saga continues</title>
		<link>http://www.last-child.com/ie7-background-sprite-bug-the-saga-continues/</link>
		<comments>http://www.last-child.com/ie7-background-sprite-bug-the-saga-continues/#comments</comments>
		<pubDate>Thu, 08 Jun 2006 17:13:39 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[background]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[position]]></category>

		<guid isPermaLink="false">http://www.last-child.com/ie7-background-sprite-bug-the-saga-continues/</guid>
		<description><![CDATA[I&#8217;ve been able to narrow down my problem with IE7b2 and background sprites. However, I still have not been able to create a stripped down test page that consistently mis-behaves. So my observations, while not scientific, could save you some hours of debugging. Internet Explorer 7beta2 is not treating transparent png background images correctly. It [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been able to narrow down <a href="http://www.last-child.com/ie7-measuring-sprites-from-bottom-up/">my problem with IE7b2 and background sprites</a>. However, I still have not been able to create a stripped down test page that consistently mis-behaves. So my observations, while not scientific, could save you some hours of debugging.</p>
<p>Internet Explorer 7beta2 is not treating transparent png background images correctly. It sees &#8220;background-position: 0 0&#8243; as &#8220;background-position: 0 100%&#8221;. Come to think of it, I have only tried a vertical sprite, this may be the same for a horizontal sprite. </p>
<h3>What&#8217;s the solution? </h3>
<p>You could create a series of rules in your IE7 style sheet to measure your new sprites from the bottom up, instead of top down. But this doesn&#8217;t solve some of the other odd issues with IE7 and transparent png images. I&#8217;ve seen the images load upside down and I&#8217;ve seen the images move when you scroll the page and the image hits the bottom of the browser. I thought I was going crazy or that I had some sort of mutated version. But this pseudo-animation works on other computers. </p>
<p>Our IE6 style sheet replaces our pretty alpha transparent png graphics with a simpler index transparent gif version. We replaced our re-measured rules in the IE7 with this set and it has solved our problems. It would be great to take advantage of IE7&#8242;s ability to use alpha transparent png images, but this bug is just driving me nuts.  I&#8217;ve also been in contact with the IE7 team. They are dedicated to building the best browser possible within their constraints and hopefully this will be figured out before the final launch of IE7. </p>
<p>One other note of advice. Creating alpha transparent png images via the save as command in Photoshop on a Mac gave us the worst results. Those images did some very funky things on the page. Fireworks created better images.</p>
<h3>c&#8217;est fini!</h3>
<p><del>I don&#8217;t know if it is official or not, but I can say that the Microsoft engineers are interested in what developers have to say and have worked on this bug. I believe it has been fixed and will be all good to go with the final release of IE7. I can&#8217;t confirm or deny this, but I am pleased with their response to my initial post and followup.</del><ins>This bug has officially been officially fixed as of Release Candidate 1 and you can use your transparent png sprites without a worry in the world!</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/ie7-background-sprite-bug-the-saga-continues/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>IE7 passes the sprite test</title>
		<link>http://www.last-child.com/ie7-passes-the-sprite-test/</link>
		<comments>http://www.last-child.com/ie7-passes-the-sprite-test/#comments</comments>
		<pubDate>Sun, 07 May 2006 17:45:55 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[background]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[Quick Tips]]></category>

		<guid isPermaLink="false">http://www.last-child.com/ie7-passes-the-sprite-test/</guid>
		<description><![CDATA[I came across an issue with Internet Explorer 7 beta displaying the rating stars incorrectly in Yahoo! Tech. After doing some testing, I realized the browser was measuring the sprite image from the bottom up, rather than the top down. This is a significant issue. I had to create a new set of rules in [...]]]></description>
			<content:encoded><![CDATA[<p><img id="image61" src="http://www.last-child.com/wp-content/uploads/2006/05/beegee-sprite-thumb.jpg" alt="beegee sprite thumb" /><br />
I came across an issue with Internet Explorer 7 beta displaying the rating stars incorrectly in <a href="http://tech.yahoo.com">Yahoo! Tech</a>.  After doing some testing, I realized the browser was measuring the sprite image from the bottom up, rather than the top down. This is a significant issue. I had to create a new set of rules in the IE7 style sheet for the new measurements.</p>
<p>I use sprites extensively. I love the way they save server requests and I think they are much easier to maintain. The thought of fixing all of my sprites was enough to send me downstairs for another coffee. But I noticed the only sprites being affected were the ratings. I needed to find what was special about these. The ratings sprites use a span that is absolutely positioned in either an unordered list or definition list. This gives us flexibility for displaying them across the site. </p>
<h3>IE7 Does it Right!</h3>
<p>I created a <a href="http://www.last-child.com/sprite-test-ie7.html">test page for using sprites</a>. I stripped the CSS down to simple list handling, floating, positioning, and sprite.  IE7 handled it perfectly. I even replaced the links with spans and that still didn&#8217;t trip up IE7.  Take a look at the test page , <a href="http://www.last-child.com/sprite-test-ie7.html">IE7 Sprite Test</a>, to see the results. While I&#8217;m still having problems with IE7&#8242;s handling of sprites. I believe it is a unique combination of styles that is causing this issue. I don&#8217;t think the average person will need to worry about this.</p>
<p>When I do figure out what is going on with Yahoo! Tech&#8217;s rating sprites, I&#8217;ll update this blog with the solution. For more information on using sprites, visit Dave Shea&#8217;s article <a href="http://www.alistapart.com/articles/sprites/">CSS Sprites: Image Slicing’s Kiss of Death</a>  on <a href="http://www.alistapart.com">A List Apart</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/ie7-passes-the-sprite-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE7 measuring sprites from bottom up?</title>
		<link>http://www.last-child.com/ie7-measuring-sprites-from-bottom-up/</link>
		<comments>http://www.last-child.com/ie7-measuring-sprites-from-bottom-up/#comments</comments>
		<pubDate>Wed, 03 May 2006 00:24:08 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[background]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Conditional Comment]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Image Sprites]]></category>

		<guid isPermaLink="false">http://www.last-child.com/ie7-measuring-sprites-from-bottom-up/</guid>
		<description><![CDATA[I&#8217;m doing some IE7 hacking and was wondering what was going on with some of my sprites. They look fine in all of the browsers except IE7. For that lovely browser, I say with my teeth clinched, I&#8217;m getting really strange results. At first I thought it was a hasLayout issue, that I needed to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing some IE7 hacking and was wondering what was going on with some of my sprites. They look fine in all of the browsers except IE7. For that lovely browser, I say with my teeth clinched, I&#8217;m getting really strange results.  At first I thought it was a hasLayout issue, that I needed to do some messing around with the position:relative, or that it just didn&#8217;t like me.</p>
<p>However, while doing some troubleshooting, it looks like, <strong>please tell me I&#8217;m wrong</strong>, lE7 is measuring the sprite from the bottom up instead of the bottom down.</p>
<p>Here&#8217;s an example on <a href="http://tech.yahoo.com/pr/Apple-iMAC-G5-Desktop-Computer/1991804229">Yahoo! Tech</a>. You should see in the top product header 4 out of 5 blue stars for Pro Reviews and 5 out of 5 red stars for User Reviews. In IE7b, there are tiny nubbins from the tips of stars. </p>
<p><a href="http://us.tech5.yimg.com/tech.yahoo.com/images/20060430165459/bg-pro-ratings.png"> Here&#8217;s the background image (.png)</a> for the pro stars and the normal CSS for 4/5 stars:<br />
<code lang="CSS"><br />
.bigprostars4 span {width:100px; height:20px; top:0; background:url(/images/bg-pro-ratings.png) no-repeat 0 -50px;}<br />
</code></p>
<p>I began looking at the numbers, thinking they were off by a few pixels. After doing some testing of the positions, I realized that it was not measuring 50px down from the top, as other browsers handle sprites, but starting at the bottom of the image and measuring 50px up! Hence, displaying the tips of the small stars.</p>
<p>To fix this I added this style to the IE7.css (currently not live!) file:<br />
<code lang="CSS">.bigprostars4 span {width:100px; height:20px; top:0; background-position: 0 -400px;}</code></p>
<p>This is not a small issue. If you use sprites as extensively as I do, this involves opening every image and re-calculating the distance from the bottom up and inserting these numbers in an IE7 only style sheet.  Please, please tell me that I need to get another cup of coffee and I&#8217;m just dreaming this.   </p>
<h3>Update (05-02): Is this a position:absolute issue in IE7?</h3>
<p>I&#8217;m still seeing this bizarre activity in the sprites of absolutely positioned elements. The sprites of links and other objects that are not positioned are working fine. sigh&#8230;</p>
<h3>Update: IE7 passes sprite test (05-07)</h3>
<p>I&#8217;ve created a test page to see if I could narrow down the issues with IE7 and sprites. I was surprised to find <a href="http://www.last-child.com/ie7-passes-the-sprite-test/">IE7 passed my initial tests</a>. It must be a unique combination of styles causing my problem. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/ie7-measuring-sprites-from-bottom-up/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Background image for visited links</title>
		<link>http://www.last-child.com/background-image-for-visited-links/</link>
		<comments>http://www.last-child.com/background-image-for-visited-links/#comments</comments>
		<pubDate>Fri, 07 Apr 2006 02:42:46 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[:absolute]]></category>
		<category><![CDATA[:relative]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML Elements]]></category>
		<category><![CDATA[Id]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[Unordered List]]></category>
		<category><![CDATA[Z-Index]]></category>

		<guid isPermaLink="false">http://www.last-child.com/background-image-for-visited-links/</guid>
		<description><![CDATA[I&#8217;ve been a recent convert to Design Meltdown. The site disects a visual theme and gives examples on how to use them and where they are being used. While exploring the latest post about sketches for the web, I noticed an interesting approach to the visited pages. The Breakdown The site has a series of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.last-child.com/wp-content/uploads/2006/04/dmelt-visited.png" alt="Visited and unvisited screenshots on designmeltdown.com" /><br />
I&#8217;ve been a recent convert to <a href="http://www.designmeltdown.com/">Design Meltdown</a>. The site disects a visual theme and gives examples on how to use them and where they are being used. While exploring the latest post about <a href="http://www.designmeltdown.com/chapters/Sketchy/">sketches for the web</a>, I noticed an interesting approach to the visited pages.</p>
<h3>The Breakdown</h3>
<p>The site has a series of floated divs to display the screenshots. The screenshot is applied as the background image of the div with an inline style.  Inside the div is a link that is given display:block and a transparent background image.<br />
<code lang="HTML"></p>
<div webdeveloper-inline-style="background-image: url(http://www.designmeltdown.com/chapters/Sketchy/1/145_115/57982515.jpg);" class="RedXContainer">
<a id="_ctl6_lnkImage" title="http://www.outhousecomm.com/home.html" class="RedXLink" href="http://www.outhousecomm.com/home.html" target="_blank"></a><br />
<a id="_ctl6_lnkScreenShot" title="View a captured screen shot" class="RedXScreenShot" href="javascript:popUp('http://www.designmeltdown.com/displaySS.html?<br />
http://www.designmeltdown.com/chapters/Sketchy/1/445/57982515.jpg')">SCREENSHOT</a>
</div>
<p></code></p>
<h3>Great idea &#8211; room for improvement?</h3>
<p>While I think the visual design for these screenshots is well thought-out. I don&#8217;t like the underlying code. The screenshots are content; miniature representations of other sites. Adding them to the CSS is treating them as decorative elements. The text for each link is: &#8220;SCREENSHOT, &#8221; making the page unusable with the styles disabled. To give this page more structure and semantic strength, I would modify the underlying code as such:</p>
<h4>HTML Code</h4>
<p><code lang="HTML"></p>
<div id="screenshotthumbs">
<ul class="screenshotlist">
<li id="ss_ctl6_lnk">
<a href="http://www.outhousecomm.com/home.html" title="This link will open a new window for you to see outhouse.com" rel="external"><br />
<img src="http://www.designmeltdown.com/chapters/Sketchy/1/145_115/57982515.jpg" alt="www.outhousecomm.com screenshot"/><br />
<strong>Visit www.outhousecomm.com to see how they've used this technique</strong><br />
</a>
</li>
<p>...
</ul>
</div>
<p></code></p>
<h4>CSS Code</h4>
<p><code lang="CSS"><br />
.screenshotlist {float:left; list-style-type:none;}<br />
.screenshotlist li {float:left; margin:9px; }<br />
.screenshotlist a {display:block; width:146px; height:130px; position:relative; }<br />
.screenshotlist a strong {text-indent:-1000em; z-index:20; position: absolute; top:0; left:0; width:100%; height:100%; background:url(screenshot.png) no-repeat -154px 0; }<br />
.screenshotlist a:visited strong {background-position:0 0;}<br />
.screenshotlist a img {margin:5px 0 0 5px; border:none; z-index:1;}<br />
</code></p>
<h3>Benefits of the new code</h3>
<p><img src="http://www.last-child.com/wp-content/uploads/2006/04/screenshot.png" alt="screenshot mask" /><br />
The screenshots now have some structure; an unordered list with links full of good, crunchy content. Screenreaders and those without CSS will have access to the information. Javascript can be used to target links within the screenshotthumb div to <a href="http://www.last-child.com/should-a-web-site-open-pdf-files-in-a-new-window/">open  a new window without the need of inline scripting</a>. </p>
<p><strong>Cavaets: </strong>I haven&#8217;t tested this code yet. It&#8217;s very possible the z-index styles are not required. As an alternative, remove the margin on the image and replace it with a border. Add a rule to change the border color on hover and visited. </p>
<p>Design Meltdown is a great site for learning about design concepts. I&#8217;ve gleaned a number of nice ideas from them and would love to say I gave a bit of help back to them. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/background-image-for-visited-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hacking to fix for IE7</title>
		<link>http://www.last-child.com/hacking-to-fix-for-ie7/</link>
		<comments>http://www.last-child.com/hacking-to-fix-for-ie7/#comments</comments>
		<pubDate>Mon, 27 Mar 2006 01:23:17 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[:absolute]]></category>
		<category><![CDATA[:block]]></category>
		<category><![CDATA[:relative]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[Conditional Comment]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Image Sprites]]></category>

		<guid isPermaLink="false">http://www.last-child.com/hacking-to-fix-for-ie7/</guid>
		<description><![CDATA[I&#8217;ve played around with IE7 for a while, but haven&#8217;t really started debugging with it until now. Fortunately, I&#8217;ve already set up the site to use conditional comments and deliver an IE6.css file and a separate IE7.css file. This has made it much easier to target the offending areas of the site. IE7 has had [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve played around with IE7 for a while, but haven&#8217;t really started debugging with it until now.  Fortunately, I&#8217;ve already set up the site to use conditional comments and deliver an IE6.css file and a separate IE7.css file. This has made it much easier to target the offending areas of the site.</p>
<p>IE7 has had a couple surprising problems for me.  I have a topnav section that completely disappeared. The container div only has <em>position:relative</em> and inside are a number of floated elements. This actuall works great in all browsers&#8230; but IE7! <strong>No hacks for IE6, but hack for IE7!</strong> I went with the old adage, I think from <a href="http://www.andybudd.com/index.php">Andy Budd</a>, when all else fails float, if it&#8217;s already floated, unfloat.  I added <em>float:left </em> to the container div and the topnav re-appeared from the IE7 void.</p>
<h3>Munged Background Images</h3>
<p>I&#8217;m using a series of positioning,  text-indent, and background images on the site.  Here&#8217;s a simplified version:</p>
<p><code lang="CSS"><br />
.targetdl dd {position:relative;}<br />
.targetdl dd span {text-indent:-1000em; width:66px; display:block;  position:absolute; top:5px; right:20px;}<br />
.happy0 span {background:url(/images/happy0.png) no-repeat 0 -650px;}<br />
</code></p>
<p>IE7 shows the background image ok on some pages and on other pages, it shrinks the background image. I tried adding zoom:1 and font-size:100% to no avail. I&#8217;ll try line-height next.  This is an odd bug, but not the first time I noticed it on IE7 betas.  It certainly seems to be buggy with positioning. </p>
<h3>De-bugging Strategy</h3>
<p>Since I&#8217;ve already got a fairly solid ie6.css file, I&#8217;m going to use that as the basis of my IE7 CSS construction.  After fixing the topnav, the rest of the ie6.css file is going into the IE7 css and rules will be removed one at a time. This should help me figure out what is still needed.</p>
<p>I&#8217;ll keep notes on this site as I find it a convenient place to remember them. Has anyone else come across some positioning bugs in IE7? Sorry, no screen shots or details at this time, we&#8217;re still pre-alpha stage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/hacking-to-fix-for-ie7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Attribute selectors to provide language information</title>
		<link>http://www.last-child.com/attribute-selectors-to-provide-language-information/</link>
		<comments>http://www.last-child.com/attribute-selectors-to-provide-language-information/#comments</comments>
		<pubDate>Sun, 26 Feb 2006 01:33:27 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[:after]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[attribute selector]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS2]]></category>
		<category><![CDATA[Image Sprites]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[padding]]></category>
		<category><![CDATA[W3C]]></category>

		<guid isPermaLink="false">http://www.last-child.com/attribute-selectors-to-provide-language-information/</guid>
		<description><![CDATA[Attribute Selectors for International Web Sites Sébastien Guillon, recently wrote a post about using the CSS2 attribute selector and content rule to let visitors know what to expect when clicking on a link to an international web site. Inspired by his approach, I’ve simplified some of the code and added background images to represent the [...]]]></description>
			<content:encoded><![CDATA[<h3>Attribute Selectors for International Web Sites</h3>
<p><a hreflang="fr-fr" href="http://sebastienguillon.com/journal/2005/10/exploiter-les-langues-avec-les-pseudo-classes-css">Sébastien Guillon</a>, recently wrote a post about using the CSS2 attribute selector and content rule<br />
to let visitors know what to expect when clicking on a link to an international web site. Inspired by his approach, I’ve simplified some of the code and added background images to<br />
represent the countries.</p>
<p>Guillon’s original project focused on adding a text description after the link in the site’s native language. To do this, he used a set of descending selectors to look at the page’s language declaration and the link’s hreflang attribute.  I am assuming the site that hosts this <acronym title="Cascading Style Sheets">CSS</acronym> is in english. However, it would not be difficult for you to simply change the generated content if your site is written in French, Spanish,<br />
Swahili, etc.</p>
<h3>Sample list of international Yahoo sites</h3>
<h4>Europe</h4>
<ul>
<li><a hreflang="ca" href="http://ct.yahoo.com/">Catalan</a></li>
<li><a hreflang="da-dk" href="http://dk.yahoo.com/">Denmark</a></li>
<li><a hreflang="fr-fr" href="http://fr.yahoo.com/">France</a></li>
<li><a hreflang="de-de" href="http://de.yahoo.com/">Germany</a></li>
<li><a hreflang="el-gr" href="http://gr.yahoo.com/">Greece</a></li>
<li><a hreflang="it-it" href="ithttp://it.yahoo.com/">Italy</a></li>
<li><a hreflang="no-no" href="http://no.yahoo.com/">Norway</a></li>
<li><a hreflang="sp-sp" href="http://es.yahoo.com/">Spain</a></li>
<li><a hreflang="sv-se" href="http://se.yahoo.com/">Sweden</a></li>
<li><a hreflang="en-gb" href="http://uk.yahoo.com/">UK </a></li>
<li><a hreflang="en-ie" href="http://uk.yahoo.com/"> Ireland</a></li>
</ul>
<p>Now look at the <a href="/international.html">final version with new <acronym title="Cascading Style Sheets">CSS</acronym></a>. Internet Explorer users will not see a difference, try <a href="http://www.mozilla.org">Firefox</a> or <a href="http://www.opera.com">Opera</a>. <ins>Internet Explorer 7 beta 2 shows the flags but does not show the generated content.</ins></p>
<h3>The hreflang Attribute</h3>
<p>The hreflang allows the user/browser to define the language of a link’s targeted page to avoid presenting<br />
unreadable information:</p>
<blockquote cite="http://www.w3.org/TR/html401/struct/links.html#adef-hreflang"><p>The hreflang attribute provides user agents with information about the language of a resource at the end of a link, just as the lang attribute provides information about the language of an element’s content or attribute values.</p>
<p><cite><acronym title="World Wide Web Consortium">W3C</acronym>.org</cite></p></blockquote>
<p>The hreflang attribute defines the language of the web site you are sending someone to. The language is defined with a two letter abbreviation, such as en, fr, sp… You can also define the locality of this language by adding the country code to this language.  This is particularly helpful for languages that have dialects. A Mexican site would have this attribute: hreflang=”sp-mx”.</p>
<h3>The Attribute Selector</h3>
<p>CSS2 allows us to look for tags that contain specific attributes.  We can look for blockquotes with cite attributes, tables with summaries, table cells with header attributes,<br />
and our little friend, the link with an hreflang attribute.</p>
<p><code lang="CSS"><br />
/*English */<br />
a[hreflang="en"]:after, a[hreflang|="en"]:after {content:"\A0(In English)";}<br />
</code></p>
<h3>Breaking it down</h3>
<p>This rule uses a combination of attribute selector and pseudo-class to transform the link from common to fabulous.</p>
<dl>
<dt> a[…]</dt>
<dd>Look for a link with an attribute</dd>
<dt>hreflang=”en”</dt>
<dd>The hreflang attribute must include the letters “en”. This allows the <acronym title="Cascading Style Sheets">CSS</acronym> to work on links that do not define a country variation</dd>
<dt>:after</dt>
<dd>This pseudoselector defines the space after the link</dd>
<dt>{content:”\A0(In English)”;}</dt>
<dd>After the link, place the following text: (In English)</dd>
<dt>hreflang|=”en”</dt>
<dd>The hreflang attribute must include the letters “en” within a hyphenated set, i.e. en-us, en-ca, …</dd>
</dl>
<h3>Adding the flag</h3>
<p>Now that we’ve notified the user about what language the link will be in, let’s tell them the country the site is from. Once again, we will look at the hreflang attribute for this information. This rule is not as neat and tidy. For each country, we are going to look for all of the possible language attributes. For instance, Canadian links could have hreflang=”fr-ca” and hreflang=”en-ca”.</p>
<p><code lang="CSS"><br />
/*Canada */<br />
a[hreflang="en-ca"], a[hreflang="fr-ca"] {background:<acronym title="Uniform Resource Locator">URL</acronym>(flag-sprite.png) no-repeat 0 0; padding-left:35px;}<br />
</code></p>
<p>This time, we will give links that have Canadian country codes 35px padding to the left side and a background image of the Canadian flag that sits to the<br />
left edge of the link’s text.  This style sheet is using an image sprite to keep the server requests to a minimum.  See the Alistapart.com article about using<br />
<a href="http://www.alistapart.com/articles/sprites">image sprites</a> for more information on this technique.</p>
<h3 lang="fr">Et Voilà</h3>
<p>There we have it. A set of international links with the country of origin and language clearly defined.  All of this has been made possible by our friends, the<br />
attribute selector, the pseudo-class, and the content style. Tune in next week as we learn how to make a cruise ship out of two<br />
shoe-boxes and an <acronym title="eXtensible Markup Language">XML</acronym> schema.</p>
<h3>Fine Print</h3>
<p>This has not been tested in Safari, but it shouldn’t be a problem. The pretty and useful presentation elements will not appear in <acronym title="Internet Explorer">IE</acronym>6, NN4, and probably<br />
most alternative devices (My Treo shows the flags but not the added content). I do not know how assistive devices would render these styles, more than likely they would be ignored. This project falls under<br />
the “build for the best, don’t hurt the rest™” protocol.</p>
<h3>Resources</h3>
<ul>
<li><a href="http://www.w3.org/TR/REC-CSS2/selector.html"><acronym title="World Wide Web Consortium">W3C</acronym> Selectors</a></li>
<li><a hreflang="fr-fr" href="http://sebastienguillon.com/journal/2005/10/exploiter-les-langues-avec-les-pseudo-classes-css">Exploiter les langues avec les pseudo-classes <acronym title="Cascading Style Sheets">CSS</acronym></a></li>
<li><a href="http://www.stuffandnonsense.co.uk/archives/css_a_tribute_to_selectors.html">A tribute to selectors</a> &#8211; Andy Clarke</li>
<li><a href="http://www.meyerweb.com/eric/articles/webrev/200008b.html">Attribute Selectors Part II</a> &#8211; Eric Meyers</li>
<li><a href="http://rollyo.com/search.html?q=hreflang&#038;sid=4886&#038;start=16">hreflang resources</a> &#8211; Standardistas</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/attribute-selectors-to-provide-language-information/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

