This grew out of a discussion regarding .ICO files and CSS on alt.html. Now, I made some mistakes in my off-the-cuff suggestion there (I used [att|=val] rather than the correct (and, annoyingly, CSS3) selector [att^=val]. After switching to the correct selector I realised that, even allowing for the simplification supplied by Toby Inkster, this would be Gecko only for now. But it is a nice trick anyway.

In essence what it does is insert a site’s favicon before any link to that site. As CSS doesn’t parse the value of att() it can’t be done on a generic level (it could be done with JavaScript but raises a number of other issues) but it can be done for sites that you link to frequently.

#content a[href^='http://groups-beta.google'] {
  background-image: url('http://www.google.com/favicon.ico');
  padding-left: 20px; background-repeat: no-repeat;
}

#content a[href^='http://www.imdb.com'] {
  background-image: url('http://www.imdb.com/favicon.ico');
  padding-left: 20px; background-repeat: no-repeat;
}

#content a[href^='http://www.amazon.co.uk'] {
  background-image: url('http://www.amazon.co.uk/favicon.ico');
  padding-left: 20px; background-repeat: no-repeat;
}

#content a[href^='http://en.wikipedia'] {
  background-image: url('http://en.wikipedia.com/favicon.ico');
  padding-left: 20px; background-repeat: no-repeat;
}
Tags:

No Comments

Leave a Comment


(will not be published unless you behave like a spammer or a troll)