Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

6. Making Tag Clouds in PHP > 6.4. Display Tags in PHP

Display Tags in PHP

There are various ways to display a tag cloud. I've chosen a style that closelyresembles the tag clouds on Flickr. Here is the HTML for a very small tag cloud, so you can see how it is structured:

<div class="cdiv">
<p class="cbox">
<a href="link1" style="font-size:23px;">tag1</a>
<a href="link2" style="font-size:18px;">tag3</a>
<a href="link3" style="font-size:13px;">tag3</a></p>

Each word or tag is associated with the style division class cdiv (which is definedin the CSS style file), and the font size is given explicitly for each tag.

These days, it is fashionable to separate style from structure, and keep all stylisticinformation in the CSS file. The tag clouds produced by some scripts accomplishthis goal by eliminating the explicit font-size references and using a set of individual styles (tagcloud1, tagcloud2, tagcloud3, and so on), one foreach font size. While the basic idea of separating style from structure is desirable, this particular method strikes me as silly, since the separate classes are functioningas implicit font-size directives. It reduces clarity in the HTML code and makes theCSS code needlessly complex.


You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free 10-Day Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint