Tag clouds markup

Tag clouds are cool though they do have some disadvantages as well. I just look at the popular ones on Flickr and noticed something wrong in the way the cloud is presented. I view the source of the page and realise that it's an ugly markup:
<p class="TagsBox">
<a href="/photos/tags/africa/" style="font-size: 12px;" class="PopularTag">africa</a>
<a href="/photos/tags/amsterdam/" style="font-size: 17px;" class="PopularTag">amsterdam</a>
<a href="/photos/tags/animal/" style="font-size: 13px;" class="PopularTag">animal</a>
<a href="/photos/tags/animals/" style="font-size: 16px;" class="PopularTag">animals</a>
<a href="/photos/tags/april/" style="font-size: 23px;" class="PopularTag">april</a>
<a href="/photos/tags/architecture/" style="font-size: 24px;" class="PopularTag">architecture</a>
<a href="/photos/tags/art/" style="font-size: 30px;" class="PopularTag">art</a>
<a href="/photos/tags/austin/" style="font-size: 12px;" class="PopularTag">austin</a>
<a href="/photos/tags/australia/" style="font-size: 23px;" class="PopularTag">australia</a>
<a href="/photos/tags/baby/" style="font-size: 23px;" class="PopularTag">baby</a>
<a href="/photos/tags/barcelona/" style="font-size: 16px;" class="PopularTag">barcelona</a>
...
</p>
How awful. The cloud shows a list of popular tags, sorted out of order, based on the popularity of the individual tag. The more popular the tag is, the bigger its font size gets. If I'm not mistaken, the font-size value should be generated from the server scripting, calculated relative to the tags' popularity.
So, let's clean it up:
<ul class="popular-tags-cloud">
<li><a href="/photos/tags/africa/" class="popular-tag-12">africa</a></li>
<li><a href="/photos/tags/amsterdam/" class="popular-tag-17">amsterdam</a></li>
<li><a href="/photos/tags/animal/" class="popular-tag-13">animal</a></li>
<li><a href="/photos/tags/animals/" class="popular-tag-16">animals</a></li>
<li><a href="/photos/tags/april/" class="popular-tag-23">april</a></li>
<li><a href="/photos/tags/architecture/" class="popular-tag-24">architecture</a></li>
<li><a href="/photos/tags/art/" class="popular-tag-30">art</a></li>
<li><a href="/photos/tags/austin/" class="popular-tag-12">austin</a></li>
<li><a href="/photos/tags/australia/" class="popular-tag-23">australia</a></li>
<li><a href="/photos/tags/baby/" class="popular-tag-23">baby</a></li>
<li><a href="/photos/tags/barcelona/" class="popular-tag-16">barcelona</a></li>
...
</ul>
I replace the p tag with ul because it's an unordered list and the tags turned into list items. I've also changed the class of the tags to be more semantic. Inline styles are removed and an external stylesheet is applied for presentational purposes, for example:
/* remove spaces and bullets */
.popular-tags-cloud{
margin: 0;
padding: 0;
list-style-type: none;
}
/* make the list items inline and add spaces between tags */
.popular-tags-cloud li{
display: inline;
margin: 0 .3em;
padding: 0;
}
/* tags' font size */
.popular-tag-10{ font-size: 10px; }
.popular-tag-11{ font-size: 11px; }
.popular-tag-12{ font-size: 12px; }
.popular-tag-13{ font-size: 13px; }
.popular-tag-14{ font-size: 14px; }
.popular-tag-15{ font-size: 15px; }
.popular-tag-16{ font-size: 16px; }
.popular-tag-17{ font-size: 17px; }
.popular-tag-18{ font-size: 18px; }
.popular-tag-19{ font-size: 19px; }
.popular-tag-20{ font-size: 20px; }
.popular-tag-21{ font-size: 21px; }
.popular-tag-22{ font-size: 22px; }
.popular-tag-23{ font-size: 23px; }
.popular-tag-24{ font-size: 24px; }
.popular-tag-25{ font-size: 25px; }
.popular-tag-26{ font-size: 26px; }
.popular-tag-27{ font-size: 27px; }
.popular-tag-28{ font-size: 28px; }
.popular-tag-29{ font-size: 29px; }
.popular-tag-30{ font-size: 30px; }
...
There, the codes look better now.
Labels: markup
Previous Posts
About
cheeaun.com is the site of a Malaysian web developer and designer, Lim Chee Aun. He loves to babble about life, computers, design, internet and oranges. Read more...
Sponsors
cheeaun Done with my theme update for #fx35 (only windows part). Time to rest and sleep. # about 4 hours ago
Archives
- June 2004
- July 2004
- August 2004
- September 2004
- October 2004
- November 2004
- December 2004
- January 2005
- February 2005
- March 2005
- April 2005
- May 2005
- June 2005
- July 2005
- August 2005
- September 2005
- October 2005
- November 2005
- December 2005
- January 2006
- April 2006
- May 2006
- June 2006
- July 2006
- August 2006
- September 2006
- October 2006
- November 2006
- December 2006
- January 2007
- February 2007
- March 2007
- April 2007
- May 2007
- June 2007
- September 2007
- October 2007
- November 2007
- December 2007
- January 2008
- February 2008
- September 2008
People
- Aaron Spuler
- Alex Choong
- Ang Kew Leok
- Angeline Tan
- Arvid Axelsson
- Asa Dotzler
- Benjamin Leow
- Bernie Zimmermann
- B.K. Ong
- Chan Lilian
- Chan Ming Shern
- Cheah Chu Yeow
- Ching Yonghan
- Chris Neale
- Chris Pirillo
- Danny Foo
- Dave Shea
- David Tenser
- Elizabeth Chin
- Eric Meyer
- Heng Kee Seng
- Ian Hickson
- James Ooi
- Jeffrey Zeldman
- Jinny Wong
- Joe Clark
- Jon Hicks
- Kamal Fariz
- Kah Soon
- Ken Lynch
- Kenny Lee Jian Siong
- Kevin Gerich
- Khai Lee
- Khoo Kah Peng
- Kong Chung Hwa
- Kuhan Venugopal
- Kwan Will Sen
- Lars Kleinschmidt
- Liew Cheon Fong
- Lim Chze Hong
- Lucia Lai
- Lun
- Navin
- Neil Turner
- P.J.Kraaima
- Peter Tan
- Regin Larson
- Ryan Lim
- Saw Kee Wooi
- Scott Jarkoff
- Soo Chooi Leang
- Steven Garrity
- Tantek Çelik
- Teoh Hock Lye
- Tim Yang
Powered By
Believe it or not, this blog is powered by Blogger. Nothing else.