There’s a little attribute in HTML links that is starting to get a bit of attention lately. The “rel” attribute is a sparsely defined attribute that applies some meta information about a link’s relationship to other documents. Unfortunately, this information is usually hidden from your users. Let’s take a light-hearted stab at turning it into a visual element.
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 Microformat community for its inherit usefulness. The rel attribute is now used for tags, to define your relationship to someone, and even to tell search engines not to bother following a link.
The opportunities to use the rel attribute are seemingly endless. There are more proposals to define people you don’t like and links for voting.
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 linking to appropriate profiles. Just simply insert the profiles into your head tag. Multiple profiles may throw a validation error, but it’s ok. You don’t need to do this for the standard rel values.
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’ll add some padding and a background image to any link that has a rel attribute. We’ll then use background positioning to display an icon that is appropriate for the link. It’s a fairly simple hack.
For more information on using attribute selectors, check out my previous posts:
I’ll be the first to admit this exercise has significant issues. I’m assuming the following elements are true:
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… I hope. Have fun with your rel attributes. They’re just sitting there waiting to be used.
View the finished rel attribute style example.
We have avoided using CSS3 rules for too long. It’s been difficult to justify using rules that won’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’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.
So, with the future of CSS3 functionality within reach, I’ve been energized to begin experimenting again. I’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?
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’ve written previously about using attribute selectors to let your users know the language of a site they are about to visit. This trick relies on the rarely used hreflang attribute, which identifies the language of the site targeted in a link.
There are many other attributes in your HTML, from table headers, image src, link titles, and selected options. Think about all of those juicy attributes just waiting to be targeted. Also think about how you could actually do something useful with them.
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’s usability in a less than perfect, but efficient way.
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:
That delivers the information to everyone, regardless of their browser. This, however takes time and is a daunting task for updating legacy code.
We can, however, use the atttribute selector to target the extension of the link to display the icon and insert the text describing the file type. Here’s the sample HTML code:
It’s a simple list of links for different types of files. We’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.
Now, let’s look at the CSS:
We have some limited “regular expression” functionality in CSS3. We can search for an attribute’s presence and match a pattern within the attribute’s value.
Patrick Hunlon has a good summary of the pattern matching:
- [foo] — Has an attribute named “foo”
- [foo="bar"] — Has an attribute named “foo” with a value of “bar” (”bar”)
- [foo~="bar"] — Value has the word “bar” in it somewhere (”blue bar stools”)
- [foo^="bar"] — Value begins with “bar” (”barstool”)
- [foo$="bar"] — Value ends with “bar” (”I was at the bar”)
- [foo*="bar"] — Value has bar somewhere (”I was looking for barstools”)
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.
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, making your page faster. This will work with any browser that recognizes attribute selectors, including Internet Explorer 7. However, support for more obscure attributes may be spotty.
There’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 FOO.ZIP, foo.Zip, or foo.zip.
Now, we are going to add a bit of descriptive text to each link. We can’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!!!).
We will also adjust the color and give it a bit of spacing.
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’s a significant improvement over nothing at all. Further, there’s no harmful effect on browsers that do not understand the function. You’ve added information, but haven’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 CSS and icons from Alexander Kaiser.
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.
Here’s an example of the information available on the Teaching with Technology site:
]]>
Lowercase Vowels à à (225) â â (226) ä ä (228) è è (232) é é (233) ê ê (234) ë ë (235) î î (238) ï ï (239) ô ô (244) œ œ (156) ù ù (250) û û (251) ü ü (252) ÿ ÿ (255)
It also includes more storage for your photographs. Here’s a sample of a video that I just posted. It’s a non-captioned capture of a train pulling into the Chemin Vert Metro stop.

Television shows have featured captioning for many years. It’s sometimes the only way to figure out what they are saying on South Park. However, captioning standards are all over the place, the quality of text is questionable, and the industry is not supporting new innovations. This sucks.
Joe Clark is working on a new standard to fix these issues. He probably knows more about captioning than any other breathing creature in the world CaptioningSucks.com is the new home to the future of captioning. Perhaps it is time to buy the domain: CaptioningRules.com, for hopefully it won’t suck much longer.
Brad at ChaoticTech has created a simple solution.
Here’s why: WordPress 2.5 has a slick new dashboard that takes use of widgets to work. K2 blocks widgets when you use Sidebar Modules (which is awesome), so WordPress 2.5 can’t get to widgets.
What this does is make it so that Widgets is disabled for everywhere so that Sidebar Modules will work, EXCEPT for the dashboard. This pretty much solves it.
Nice and simple.
K2 + WordPress 2.5 = Broken? I can fix that
Visit Chaotic Tech for the php code. You’ll simply over-write the widgets-removal.php file. Thanks Brad, you’ve saved me a ton of headaches.
I’ve come across a problem that should be easy to solve. Wordpress allows you to create a category whose posts are displayed differently than other category posts. These “asides” are short posts that appear in the side bar and not in the main body of the blog. This functionality is baked into the latest versions of Wordpress and the K2 theme’s admin screen makes it really easy to use.
However, I need to add a second variation of the asides. I want to create a new landing page with three promo spots just below the topnav. This branding section would allow the site to highlight important features, promos, sales, or blog posts. This could be done with asides, however I don’t want to lose the functionality of asides in the blog section.
I’ve started by cloning the asides module and functionality and creating a new set of functions (promos). The admin screen now allows you to choose a category that will be defined as a promo. Everything seems to be working until you get to the blog post page. Blog posts labeled as the asides category appear as they should.
However, the promos category and promo posts are not following the aside functionality. I’ve looked at the loop to see where it excludes the asides category and can’t find it. I can’t find the “the_post()” function, which may be the source of the issue. I would assume that the promos module is telling the_post that “promos” category is special and these posts should not be included in the loop, nor in the category list.
Have you worked with the asides functionality in Wordpress? Do you have any suggestions? I’ll post a summary when I get the solution figured out.
Here’s a list of related web pages that include information but haven’t answered my questions.
The above link for the loop has some interesting information on multiple loops within one page. I’m going through the examples for some answers. Here’s a snippet of the post:
Loop Examples
Below are two examples of using multiple loops. The key to using multiple loops is that $wp_query can only be called once. In order to get around this it is possible to re-use the query by calling rewind_posts() or by creating a new query object. This is covered in example 1. In example 2, using a variable to store the results of a query is covered. Example 3 documents the use of the update_post_caches(); function to avoid common plugin problems. Finally, ‘multiple loops in action’ brings a bunch of ideas together to document one way of using multiple loops to promote posts of a certain category on your blog’s homepage.
Wordpress Codex: The Loop
During my initial modification of the files, I missed an important line that tells the loop to honor a new filter. So, if you want to duplicate the asides functionality with a new category, add this new section to wordpress/wp-content/themes/k2/app/includes/info.php
In a fit of cleverness, I changed the naming convention on my promos from promos_sidebar_module to promos_module. This threw my code off for a while.
This is the rough draft of my promos.php file that sits in wordpress/wp-content/themes/k2/app/modules/promos.php
There are also some changes in the options.php file and sbm section. Do a search for asides and start replacing with your new function, i.e. promos.
The next step in this process was to make sure the promos category (and asides) don’t appear in the category and latest posts modules. These two modules sit inside the /k2/app/modules/ folder. They also use similar logic. We need to create a comma delimited list of categories to exclude from the functions that build the appropriate lists.
This code checks for aside and promos categories. It then creates a comma separator and then combines the categories into a string, i.e. “12,13″
For the latest posts, we’ll need to create a slightly different string. We need to create a parameter and add a negative sign to each category
actually, this is bad logic, I need to only add the - if the category exists. That’s what is great about blogging your code. You realize your mistakes before it is too late.
Finally, we use that excludes variable in the logic to hide the categories, for example (categories.php)
These snippets assume you do not want to include your asides posts into the latest posts and categories modules. you can simplify the code if you only want to exclude the promos.
]]>This set of hacks allowed us to control IE7 and IE6. However, IE8 does not recognize the * hack. Special IE8 rules will either need to be defined with conditional comments, the Microsoft proposed meta tag, or some new hack to be discovered. Let’s hope the mature version of IE8 will reduce the need for these hacks.
For more information on the above hacks, visit an earlier post: IE7 Hacks
]]>You can download Internet Explorer 8, Beta 1 from the Microsoft Developer site. However, here are a few things to keep in mind:
It’s still really early to find all of the bugs and benefits of the new browser. The team needs to be commended for the fast development and their willingness to listen to criticism and change the default behavior at such a late point. I look forward to the more mature releases.
Yahoo’s Christian Heilmann has been advocating layered, semantic badging.
Yahoo! Media Player has taken this approach to embedding music. You simply put a link to a music file in your site, insert the music JavaScript and away you go. The Music Badge Twiki also shows how you can extend the functionality with basic HTML elements, such as adding a title attribute or image inside the link.
Here’s an example of the badge in effect.
Orca live at the Casbah, 1992 I made a bootleg recording of Orca, a San Diego supergroup circa 1993. I’m simply going to create a basic link to the music file and include an optional image from flickr. The JavaScript will use that information for the player to appear. You’ll see page loads with a little play icon next to the link. There’s also a small player on the side of the browser. Click on either and you’ll see a media player appear in your browser with the music controls.
Here’s the code:
]]>