Oct 22

Highlighting different link types part 2

Highlighting Downloadable documents and feeds

Another common frustration is clicking on a link thinking it is going to take you to a page only for it to start downloading a PDF or Microsoft Word document. Luckily, CSS can help us distinguish these types of links as well. This is done using the [att$= val] attribute selector, which targets attributes that end in a particular value, such as pdf or .doc:

Example:

a[href=".pdf"] {
background:url(images/pdflink.gif) no-repeat right top;
padding-right: 10px;
}
a[href=".doc"] {
background:url(images/wordlink.gif) no-repeat right top;
padding-right: 10px;
}

So in a similar way to the previous examples, you can highlight links to word documents or PDFs with their own separate icon, warning people that they are downloads rather than links to another page

Lastly, many people have RSS feeds on their website well specially blogs like WordPress. The idea is for people to copy these links into their feed readers. However, inadvertently clicking one of these links may take you to a page of seemingly meaningless data to avoid possible confusion. You could highlight RSS icon:
a[href=".rss"] {
background:url(images/rsslink.gif) no-repeat right top;
padding-right: 10px;
}

Tagged with:
Oct 16

Highlighting different link types part 1

Highlighting different types of link

Some of you might already know this technique but for people still learning CSS this might help you.

A link from your website to an external page can be highlighted without using a class or an id for each anchor.

To identify if your link an external link using [href^="http:"]
#container p a[href^="http:"] {
  background: url(images/externalLink.gif) no-repeat right top;
  padding-right: 10px;
}

#container p a[href^="http://www.bestwebbuzz.com"], a[href^="http:// bestwebbuzz.com"]  {
  background-image: none;
  padding-right: 0;
}

<div id=”container”>
<p><a href=”http://www.google.com/”>This is an external link</a></p>

this is how it would look like

External Link Screen Shot
External Link Screen Shot

 

Links mixed with internal and external links
<p>And here is a reasonably long line of text containing  an <a href=”http://www. bestwebbuzz.com/index.php”>absolute internal link</a>, some text, an <a href=”http://www.yahoo.com/”>an external link</a>, some more text, a <a href=”css-button.htm”>relative internal link</a> and then some more text.</p>
</div>

this is how it would look like

mixed with internal and external links

mixed with internal and external links

 

You can even do it with this links

mailto:

aim:

<p>Contact me by <a href=”mailto:info@andybudd.com”>email</a><br />
Send me an <a href=”aim:goim?screenname=andybudd”>instant message</a> using AIM/iChat.</p>

This is how it would look like

highlighting im and email links
highlighting im and email links

Unfortunately this does work on IE6 but work on modern browsers.

You can download source here external_link

 

This post will be continueed on the next post so watch out for that.

Tagged with:
preload preload preload