<?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; Link</title>
	<atom:link href="http://www.last-child.com/category/html-elements/link/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>Create a tabbed search form with YUI</title>
		<link>http://www.last-child.com/tabbed-search-form-yui/</link>
		<comments>http://www.last-child.com/tabbed-search-form-yui/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 14:00:59 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[Online Resource]]></category>
		<category><![CDATA[Yahoo!]]></category>
		<category><![CDATA[YUI]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.last-child.com/?p=159</guid>
		<description><![CDATA[Yahoo! makes it easy to create an accessible, handsome tabbed interface. I used their Tab View library to create the tabbed search form for V3GGIE.com. While Tab View can create the tabbed content dynamically, I&#8217;m using it to hide/show hard-coded individual forms. Update: I&#8217;ve removed the tabbed interface from V3GGIE.com. This particular use of the [...]]]></description>
			<content:encoded><![CDATA[<p>Yahoo! makes it easy to create an accessible, handsome tabbed interface. I used their Tab View library to create the tabbed search form for <a href="http://v3ggie.com">V3GGIE.com</a>. While Tab View can create the tabbed content dynamically, I&#8217;m using it to hide/show hard-coded individual forms.</p>
<p><ins datetime="2008-09-28T16:10:07+00:00"><strong>Update:</strong> I&#8217;ve removed the tabbed interface from V3GGIE.com. This particular use of the tabbed module seemed to have created some confusion in users. The approach is still valid, just not the way I originally implemented it.</ins><a href="http://v3ggie.com"><img src="http://www.last-child.com/wp-content/uploads/2008/09/v3ggie-form-300x45.png" alt="" class="alignnone size-medium wp-image-160" height="45" width="300"> See the tabbed search form on V3GGIE.com </a></p>
<h3>Step 1. Create the basic HTML code.</h3>
<p>The tabbed code is a simple pattern: </p>
<ol>
<li>Start with a parent div and give it an id and class=&#8221;yui-navset&#8221;.<br />
	  <code lang="HTML">
<div class="yui-g yui-navset" id="v3search"></div>
</li>
<p></code></p>
<li>Create an unordered list inside this div with class=&#8221;yui-nav&#8221;.</li>
<li>Each list includes a deep link to a corresponding div that is also a child of the parent div. The link text in an em tag.<br />
	  <code lang="HTML">
<li><a href="#vesearch"><em>V3GGIE Search</em></a></li>
<p></code></li>
<li>Create a div with class=&#8221;yui-content&#8221; and create a set of content containing divs. Each div has an id.<br />
	  <code lang="HTML"></p>
<div class="yui-content">
<div id="vesearch">...</div>
<div id="losearch">...</div>
<div id="rcsearch">...</div>
</p></div>
<p></code>
	</li>
<li>Insert the Tabview CSS at the top of the page, the Tab View JS at the bottom of the page, create a small js that instantiates the tab-view module.</li>
<li>For easier styling, use the sam_skin CSS package and add class=&#8221;yui-skin-sam&#8221; to the body.</li>
</ol>
<h3>Step 2. Use PHP to make it more interesting</h3>
<p>Each page calls this chunk of code to insert the tabbed form, it also sets a variable ($selected),  determining which tab is selected on page load. I&#8217;m also inserting the last search query into the text input to make it easier on the user. This is easily done by grabbing the query from the Request object. </p>
<p>The finished code: </p>
<p>	<code lang="PHP"></p>
<div class="yui-g yui-navset" id="v3search">
<!--<?php print $selected ;?>--></p>
<ul class="yui-nav">
<li> &gt;<a href="#vesearch"><em>V3GGIE Search</em></a></li>
<li> &gt;<a href="#losearch"><em>Local</em></a></li>
<li> &gt;<a href="#rcsearch"><em>Recipes</em></a></li>
<li> &gt;<a href="#nesearch"><em>News</em></a></li>
<li> &gt;<a href="#blsearch"><em>Blogs</em></a></li>
</ul>
<div class="yui-content">
<div id="vesearch">
<form name="b" action="/results.php" method="get">
   <label for="vquery">Search for Vegetarian information</p>
<input id="vquery" size="50" name="query" value="&lt;?php print $inputtext; ?&gt;" type="text"></label></p>
<input class="searchsubmit" value="Search" type="submit">
   </form>
</p></div>
<div id="losearch">
<form name="b" action="/local/results.php" method="get">
   <label for="lquery">Where do you want to eat?</p>
<input size="50" id="lquery" name="query" value="&lt;?php print $inputtext; ?&gt;" type="text"></label></p>
<input class="searchsubmit" value="Search" type="submit">
<p>Try "San Francisco Pho", "Paris Fromage",  or "92104 tofu"</p>
</p></form>
</p></div>
<div id="rcsearch">
<form name="b" action="/recipes/results.php" method="get">
   <label for="rquery">What are you hungry for?</p>
<input size="50" name="query" id="rquery" value="&lt;?php print $inputtext; ?&gt;" type="text"></label></p>
<input class="searchsubmit" value="Search" type="submit">
<p>Try "corn chowder" or "vegan pizza"</p>
</p></form>
</p></div>
<div id="nesearch">
<form name="b" action="/news/results.php" method="get">
   <label for="nquery">Get Vegetarian news?</p>
<input size="50" id="nquery" name="query" value="&lt;?php print $inputtext; ?&gt;" type="text"></label></p>
<input class="searchsubmit" value="Search" type="submit">
<p>Try "Vegetarian Chinese Olympics"</p>
</p></form>
</p></div>
<div id="blsearch">
<form name="b" action="/blogs/results.php" method="get">
   <label for="bquery">What are the blogs saying?</p>
<input size="50" id="bquery" name="query" value="&lt;?php print $inputtext; ?&gt;" type="text"></label></p>
<input class="searchsubmit" value="Search" type="submit">
<p> Try a subject: "PETA", "Tempeh", or "Paris -Hilton Vegetarian"</p>
</p></form>
</p></div>
</p></div>
</p></div>
<p></code></p>
<p><a href="http://v3ggie.com/search-form.txt">View the source as a text file</a></p>
<h3>The Final Product</h3>
<p>We now have a tabbed module that allows the user to find recipes, news, blogs, and local restaurants from any page. This is an easy introduction to the <a href="http://developer.yahoo.com/YUI/">YUI</a> libraries. However,  I came across the following surprises:</p>
<ul>
<li>The order of the tabs must match the order of the target divs. I moved my tabs around and discovered they were toggling the wrong forms.</li>
<li>The links that generate the tabs need to have em tags surrounding the text</li>
<li>You&#8217;ll need to download the entire <a href="http://sourceforge.net/project/downloading.php?group_id=165715&amp;filename=yui_2.5.2.zip">YUI package</a> to gain access to the CSS and sprites needed for the library. The examples on the YUI site assume relative links to files, you will either need to duplicate that file structure or upload the skin&#8217;s sprite and change the CSS accordingly. </li>
</ul>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://woork.blogspot.com/2008/07/navigation-bar-with-tabs-using-css.html">Navigation bar with tabs using CSS and sliding doors effect</a></li>
<li class="zemanta-article-ul-li"><a href="http://ajaxian.com/archives/filament-groups-accessible-extensions">Filament Group&#8217;s Accessible Extensions</a></li>
<li class="zemanta-article-ul-li"><a href="http://www.stylegala.com/news/public200809/4777.htm">jQuery Nested Menu</a></li>
<li class="zemanta-article-ul-li"><a href="http://ajaxian.com/archives/the-lessons-of-css-frameworks">The lessons of CSS frameworks</a></li>
<li class="zemanta-article-ul-li"><a href="http://ajaxian.com/archives/rounded-tabs-with-dijit">Rounded tabs with Dijit</a></li>
<li class="zemanta-article-ul-li"><a href="http://jtame05.wordpress.com/2008/06/16/dynamic-css-yet-another-follow-up/">Dynamic CSS (Yet another follow up)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/tabbed-search-form-yui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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 replacement and screenreaders</title>
		<link>http://www.last-child.com/image-replacement-and-screenreaders/</link>
		<comments>http://www.last-child.com/image-replacement-and-screenreaders/#comments</comments>
		<pubDate>Thu, 20 Apr 2006 02:04:32 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Image Replacement]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[text-indent]]></category>

		<guid isPermaLink="false">http://www.last-child.com/image-replacement-and-screenreaders/</guid>
		<description><![CDATA[Ok kids, if you use image replacement to create super-cool rollover buttons, raise your hands. Good. Now, keep your hands raised if you put title attributes on the links to give added information. Great! What is the text inside the link? Keep your hands raised if you repeated your title attribute in the link text. [...]]]></description>
			<content:encoded><![CDATA[<p>Ok kids, if you use <a href="http://phark.typepad.com/phark/2003/08/accessible_imag.html">image replacement</a> to create super-cool rollover buttons, raise your hands.  Good. Now, keep your hands raised if you put title attributes on the links to give  added information.  Great!  What is the text inside the link? Keep your hands raised if you repeated your title attribute in the link text.</p>
<p><strong>Congratulations</strong>, you&#8217;ve probably done some usability testing with an actual screen reader.  </p>
<p>For those who put your hands down; here&#8217;s the deal-eeo.  Screenreaders ignore title attributes by default. Sucks&#8230; I know.  I&#8217;ve been adding really juicy title attributes for usability and they&#8217;re being ignored!  </p>
<h3>Go ahead and duplicate your text</h3>
<p>I was doing some user-testing today with <a href="http://www.victortsaran.com/">Victor Tsaran</a>, the <a href="http://blog.360.yahoo.com/blog-cXwqpNonb7W4nud89xms">Accessibility Project Manager</a> at Yahoo! He came across a button with link text that was the same as the image. He said, &#8220;what&#8217;s this going to do?&#8221;  It was a simple thing like &#8220;more info&#8221;&#8230; But the title attribute said &#8220;Visit Joe&#8217;s Web Site for more information.&#8221;  That, he suggested, should have been the link text. </p>
<p>The link text is hidden from the visual users and the title attribute is hidden from the screen readers; so duplicating the information isn&#8217;t a bad thing. If you find yourself putting good information in a title attribute for a link that is using image replacement, duplicate the content in the link. It&#8217;s that simple.  Now, put your hands down, it&#8217;s starting to smell musky around here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/image-replacement-and-screenreaders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get rid of the dotted lines on links with image replacement</title>
		<link>http://www.last-child.com/get-rid-of-the-dotted-lines-on-links-with-image-replacement/</link>
		<comments>http://www.last-child.com/get-rid-of-the-dotted-lines-on-links-with-image-replacement/#comments</comments>
		<pubDate>Tue, 18 Apr 2006 17:15:40 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[:focus]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[text-indent]]></category>

		<guid isPermaLink="false">http://www.last-child.com/get-rid-of-the-dotted-lines-on-links-with-image-replacement/</guid>
		<description><![CDATA[I don&#8217;t remember where I first found this tip (Hedger Wang?), but it&#8217;s a good one. If you are using image replacement, i.e. background images and negative text-indent, you may notice a dotted line appear when the link is clicked and waiting for the page to change (:focus). It&#8217;s outlining the text that happens to [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t remember where I first found this tip (Hedger Wang?), but it&#8217;s a good one. If you are using image replacement, i.e. background images and negative text-indent, you may notice a dotted line appear when the link is clicked and waiting for the page to change (:focus). It&#8217;s outlining the text that happens to be wayyyyy off screen. It&#8217;s easy as pie to fix this issue.</p>
<h4>CSS Fix</h4>
<p>This will fix the problem in Firefox. Just drop this into your global.css file.<br />
<code lang="CSS"><br />
a:focus { -moz-outline-style: none; }/*this avoids having image replacement sections display a dotted outline*/<br />
</code></p>
<h4>JavaScript Fix</h4>
<p>This will fix the issue in the other browsers.<br />
<code lang="Javascript"><br />
var theahrefs = document.getElementsByTagName('a');<br />
//fix dotted line thing when link is OnClicked<br />
for(var x=0;x!=theahrefs.length;x++){<br />
theahrefs[x].onfocus = function stopLinkFocus(){this.hideFocus=true;};<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/get-rid-of-the-dotted-lines-on-links-with-image-replacement/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>Should a web site open pdf files in a new window?</title>
		<link>http://www.last-child.com/should-a-web-site-open-pdf-files-in-a-new-window/</link>
		<comments>http://www.last-child.com/should-a-web-site-open-pdf-files-in-a-new-window/#comments</comments>
		<pubDate>Sun, 26 Feb 2006 03:03:38 +0000</pubDate>
		<dc:creator>Ted</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Link]]></category>

		<guid isPermaLink="false">http://www.last-child.com/should-a-web-site-open-pdf-files-in-a-new-window/</guid>
		<description><![CDATA[A few years ago, I was visiting some friends in Paris. One is a fairly conservative priest and the other a socialist teacher. I asked them a seemingly innocent question: What’s the deal with Robespierre? Why do people feel so strongly one way or another about him? I had just begun learning about the French [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago, I was visiting some friends in Paris. One is a fairly conservative priest and the other a socialist teacher.<br />
I asked them a seemingly innocent question: What’s the deal with Robespierre? Why do people feel so strongly one way or another about him?</p>
<p>I had just begun learning about the French Revolution and was not prepared for the argument that arose. Robespierre and the<br />
Reign of Terror still divide people into camps.</p>
<p><img alt="pdf file icon" src="http://www.tdrake.net/images/PDF_icon.gif" /><br />
It’s rare to find a topic with such strong opinions expressed in web design (not counting Internet Explorer). However, I recently found the<br />
standardista populace building ramparts in the streets of the city when I asked the seemingly innocent question: &#8220;Should .pdf files be<br />
opened in a new window?&#8221;</p>
<h3>The answers fall into two main camps:</h3>
<ol>
<li>Do not hijack the browser; let the user determine the behavior of their browser.</li>
<li>Make it easier for visitors that are not savvy enough to know how to control their browser’s options.</li>
</ol>
<h3>Hypothetical vs. Reality</h3>
<p>In a perfect world, information is provided efficiently in all browsers to people of all abilities. <abbr lang="en" title="HyperText Markup Language"><acronym title="HyperText Markup Language">HTML</acronym></abbr> code should not interfere with the<br />
browser’s native behavior, allowing the user to establish preferences for font size, background-color, and file downloading.</p>
<p>In the real world, the visitor has to wait for files to be presented, can lose track of the original web page, and can accidentally shut down<br />
the browser instead of the file. Therefore, the programmer can assist the viewer by opening the file in a new window.</p>
<p>I’ve summarized the recent comments over this question (from the web standards group mailing list) to decide which is the best approach.</p>
<h3>Basic standards</h3>
<p>Regardless of the window option you choose, there are some elements that everyone agrees upon. The link must let the visitor know that<br />
they are opening something other than another web page. The file type and file size should be attached to the link, i.e.: <code>&lt;a href="foo">contact list (.pdf, 25kb)</a&gt; </code>. This gives the visitor the basic information needed to make an informed decision about how the file should be opened.</p>
<p>The developer could also give the link more information to assist the visitor: <code>&gt;a  href="foo">contact list (.pdf, 25kb)</a&lt; </code>. If the visitor does not have the required plug-in, they should be given<br />
a link to the appropriate download site. <code>&lt;a href="foo">contact list&lt;/a> (&lt;a href="foo"   title=”Download the plugin required to view a Portable Document Format file”>.pdf, 25kb &lt;/a>)</code> .<br />
<acronym title="Cascading Style Sheets">CSS</acronym> can also be used to place the Acrobat icon next to the link:</p>
<h3>Version 1:</h3>
<dl>
<dt>HTML: </dt>
<dd><code>&lt;a   href="foo"&gt;contact list (.pdf, 25kb)&lt;/a&gt;</code></dd>
<dt>CSS: </dt>
<dd><code>.pdfFile {background: url(pdflogo.gif) no-repeat 0 0; padding-left:25px;} </code></dd>
</dl>
<h3>Version 2:</h3>
<p>Use JavaScript to find links with .pdf in the href and insert the class=”.pdfFile” dynamically</p>
<h3>Version 3:</h3>
<p>Use CSS3 syntax to add the icon to all links with .pdf in the href. IE6 does not support this, which makes this option impractical for now.</p>
<p>Let the visitor know that the link is to something other than another web page. The easiest method is to follow the link with the file name<br />
and size; all other additions are usability gravy.</p>
<h2>Do not open new windows</h2>
<p>"pop-up" windows are bad for accessibility and usability. The WAI answers the "pop-up" question quite plainly:</p>
<blockquote cite="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">
<h3>WAI Checkpoint 10.1</h3>
<p>Until user agents allow users to turn off spawned windows, do not cause "pop-ups" or other windows to appear and do not change the current window without informing the user.</p>
<p><cite><a href="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">http://www.w3.org/WAI/wcag-curric/sam77-0.htm</a> </cite></p></blockquote>
<p>However, the first part of this rule has been satisfied. Modern web browsers now block unwanted popup windows. This rule seeks to prevent web sites from launching new windows when a visitor comes to the site. The second part of the rule requires the visitor to be warned that such behavior may happen. This requirement does not banish new windows altogether, rather those that the visitor has no control over.</p>
<p>Many people believe that the visitor should have control over their browser or other rendering device at all times. The savvy user will know how they prefer to see a file and the web site should not pre-determine this action.</p>
<blockquote><p>I would say let the user decide. Wherever possible I try to provide enough information in the link itself so that the user knows what to<br />
expect and can proceed as they wish. Many people will set up their browser to deal with different file types according to their preference<br />
(open the document in the browser, open it in the application, download the file). Opening in a new window removes user choice. By providing a<br />
plain link you give users the option … of `right-click - open in new window`.</p>
<p><cite>- Damian <a href="http://airport.unimelb.edu.au">airport.unimelb.edu.au</a></cite></p></blockquote>
<p>Users with assistive technology or portable devices also have difficulties with multiple windows.</p>
<blockquote><p>Accessibility considerations would be ensuring that users are advised of what will happen when they activate the link, either that the<br />
document would be opened in a new window, or that it will be downloaded. Also that opening a new window does not adversely effect users<br />
accessing a website with assistive technologies (screen readers, etc.).</p>
<p><cite>- Andy Kirkwood | Creative Director   <a href="http://www.motive.co.nz/">http://www.motive.co.nz </a></cite></p></blockquote>
<p>These issues need to be addressed if the web site chooses to open these links in a new window.</p>
<h2>The argument for opening new windows</h2>
<p>The Internet is not full of expert users. That is the simple reality. An effective web site compensates for visitor behavior and creates a seamless experience. While this is not always possible, the programmer can minimize frustrations. Opening a document in the original window creates its own set of problems for the user. Even the savvy visitor will sometimes forget to right-click on a link and choose “open in a new window” or “save target as.”</p>
<p>Many of our users are very computer illiterate and giving them too many options confuses them. We do open our <acronym title="Portable Document Format">PDF</acronym> documents in a new window and never have any complaints about it.</p>
<blockquote><p>We DO get complaints, though, when things are too hard to use or if the page they were on "disappears" because we opened a "document" in that same window or if the file downloaded and they can’t find it (happened regularly before we launched the <acronym title="Portable Document Format">PDF</acronym> in another window).</p>
<p><cite>Gary Menzel,  Senior Software Engineer, <a href="http://www.medeserv.com.au/">Med-E-Serv Pty Ltd</a></cite></p></blockquote>
<p>Many users have become accustomed to having windows appear to log-in, handling web applications, for advertisements, help sections, and more. Further, they are used to closing the windows by clicking on the browser’s close button. When the <acronym title="Portable Document Format">PDF</acronym> document loads in the original window, the visitors will often close the browser, expecting the original web site to appear. Instead, they have closed the web browser and will have to navigate their way back to the original page. For many, this may involve doing another search if they are not comfortable using the history feature.</p>
<blockquote><p>… I’ve had users report that they close the window thinking that they’re exiting the document, but they’re actually closing the browser.</p>
<p><cite>Mario, <a href="http://www.webnetdesignstudios.com/">www.webnetdesignstudios.com </a></cite></p></blockquote>
<p>Opening the documents in a new window can create a friendlier environment for the user. It preserves the original page and allows the visitor to continue reading the web site while the new file is being prepared in another window. However, it needs to be done in a manner that does not violate accessibility requirements.</p>
<h3>JavaScript to the rescue</h3>
<p>In the past, links were given a target to choose which window a link was opened in. This was meant for web sites using frames. Open the<br />
link in the top, side, body, footer, etc. A new window could also be generated if the page was not using frames or if the targeted id did<br />
not exist in the frameset. Target=”_blank” became the standard code for opening a new window: <code>&lt;a target="blank" href="foo" /></code>.</p>
<p>However, this assumes the visitor is able to keep visual track of the windows. It also does not account for browsing devices that do not<br />
recognize multiple windows.  </p>
<h3>There are two methods for using JavaScript to make a link open a new window.</h3>
<h3>Insert the script into the link code</h3>
<dl>
<dt><acronym title="HyperText Markup Language">HTML</acronym> </dt>
<dd><code >&lt;a onclick="window.open(this.href); return false;" href="foo"><acronym title="Portable Document Format">PDF</acronym> file in a new window” class=”pdfFile”&gt;contact list (.pdf, 25kb)</a> </code></dd>
</dl>
<p>This script tells the browser to open a window with the <acronym title="Uniform Resource Locator">URL</acronym> listed in the href. If the browser does not recognize the window.open command,<br />
ignore the function and open the link in the original window.</p>
<h3>Removing the script from the link</h3>
<p>Thierry Koblentz of <a href="http://www.TJKDesign.com">TJK Design</a> developed the following JavaScript for this article.  The script searches for  any file downloaded as application/pdf, that sits in a folder named “<acronym title="Portable Document Format">PDF</acronym>”, or has the extension of .pdf. It then adds class=”pdfFile” for the <acronym title="Cascading Style Sheets">CSS</acronym>, a title attribute to notify the visitor that the link will open a new window, and gives the programmer the option of using target=”_blank” or window.open to create the new window.</p>
<dl>
<dt><acronym title="HyperText Markup Language">HTML</acronym> </dt>
<dd><code>&lt;a href="foo">contact list (.pdf, 25kb)&lt;/a></code> </dd>
<dt>JavaScript (<a href="http://www.tjkdesign.com/articles/popups.asp">http://www.tjkdesign.com/articles/popups.asp</a>) </dt>
<dd> 	<code> </p>
<ol>
<li>function TJKpopAppPdf(){ // v1.0 | <a href="http://www.TJKDesign.com">www.TJKDesign.com </a></li>
<li>var zA=document.getElementsByTagName(’a');</li>
<li>for (var i=0;i</li>
<li>// This is if the href value contains the string “.pdf” or if the anchor contains the correct “type” attribute or if the file is stored in a <acronym title="Portable Document Format">PDF</acronym> folder</li>
<li>if (zA[i].getAttribute(’href’) != null &#038;&#038;</li>
<li>(zA[i].getAttribute(”type”)== “application/pdf” ||</li>
<li>zA[i].getAttribute(’href’) .toUpperCase().indexOf(”.PDF”) >= 0 ||</li>
<li>zA[i].getAttribute(’href’) .toUpperCase().indexOf(”<acronym title="Portable Document Format">PDF</acronym>/”) >= 0)){</li>
<li>// This is to include a title attribute or attach a string to an existing title’s value</li>
<li>zA[i].title+=’ (opens in new window)’;</li>
<li>// This is to include a class or attach one to an existing class’ value</li>
<li>zA[i].className+=zA[i].classNam e?’ pdfFile’:'pdfFile’;</li>
<li>// This spawns multiple windows, but works fine with popup blockers</li>
<li>// zA[i].target=’_blank’;</li>
<li>// This opens a unique window and brings it in front of the opener each time the user clicks on the link</li>
<li>zA[i].onclick=function() {newWin=window.open(this.href,’TJKWin’,'toolbar=no’);</li>
<li>if( window.focus){newWin.focus()} return false;}</li>
<li>}</li>
<li>}</li>
<li>}</li>
<li>window.onload=function(){if(document.getElementById) TJKpopAppPdf()};</li>
</ol>
<p></code>
</dd>
</dl>
<p>The name TJKWin is given to the new window to assure that all <acronym title="Portable Document Format">PDF</acronym> links open in the same window. This keeps the visitor from ending up with a plethora of new windows for each <acronym title="Portable Document Format">PDF</acronym> they open.  If the browsing device is not capable of opening new windows, it will ignore the script and simply open the link in the existing window.</p>
<p>If you expect your audience to compare multiple files, you may want to remove the window name designation from the script.</p>
<blockquote><p>Opening all documents in a window with the same name is obviously ‘tidy’, but problematic if a user wants to open and compare the contents of two documents simultaneously.</p>
<p><cite>Andy Kirkwood</cite></p></blockquote>
<h2>Other file types</h2>
<p>This still leaves the discussion open for other file types. Should a new window be opened for spreadsheets, PowerPoint presentations, Visio documents, <acronym title="eXtensible Markup Language">XML</acronym> files, and more? Some of these files can be viewed in the browser, but they would be better left as a downloaded document to be viewed natively. The visitor still needs to be notified the link is for a non-<acronym title="HyperText Markup Language">HTML</acronym> link:</p>
<dl>
<dt>HTML: </dt>
<dd><code>&lt;a  class="”exceldownload”" href="foo">contact.xls (.xls, 25kb)&lt;/a></code></dd>
</dl>
<p>The previous javascript could also be modified to give .xls files the appropriate class and title, making the code even cleaner.</p>
<h2>Summary</h2>
<p>Web site visitors expect to find information in an efficient, user-friendly manner. It is up to the web designer to create this experience. While opening new windows may be considered a faux pas, the average user will actually appreciate its convenience. JavaScript offers the most convenient method of giving a visual reference and functionality. Placing a helpful title attribute within the link further informs the visitor about the link’s behavior.</p>
<p><ins> To further avoid confusion for the visitor, Thierry changed the code slightly today. He added  <code>,'toolbar=no'</code> to remove the browser’s toolbar: <code>(window.open(this.href,'TJKWin','toolbar=no');)</code>. This approach was suggested by Jacob Nielsen’s Alertbox <a href="http://www.useit.com/alertbox/open_new_windows.html">Open New Windows for <acronym title="Portable Document Format">PDF</acronym> and other Non-Web Documents</a>.</ins></p>
<h3>Resources</h3>
<ul>
<li><a href="http://www.motive.co.nz/glossary/popup.php">Motive Glossary: <acronym title="Short for POP3, the Post Office Protocol for email">POP</acronym>-up Windows</a></li>
<li><a href="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">WAI Accessibility Requirements</a></li>
<li><a href="http://www.alistapart.com/articles/pdf_accessibility">Facts and Opinions About <acronym title="Portable Document Format">PDF</acronym> Accessibility</a></li>
<li><a href="http://www.alistapart.com/articles/popuplinks">Accessible <acronym title="Short for POP3, the Post Office Protocol for email">POP</acronym>-up Links</a></li>
<li><a href="http://www.accessify.com/tutorials/standards-compliant-new-windows.asp">Standards-Compliant New Windows - Extending <acronym title="eXtensible HyperText Markup Language - HTML reformulated as XML">XHTML</acronym></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.last-child.com/should-a-web-site-open-pdf-files-in-a-new-window/feed/</wfw:commentRss>
		<slash:comments>5</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>

