views:

70

answers:

1

I have a tag cloud and I need to know how can I change the font-size for the most used tags.

I need to set a min-font-size and a max-font-size.

+3  A: 

You could use a linear or logarithmic assessment of the number of items associated with a certain tag relative to the largest tag, multiply it by the difference between minimum and maximum font sizes, then add it to the minimum font size. For example, the math in pseudocode might be:

let min = 12, max = 24
for each tag
    font = (items / items in biggest tag) * (max - min) + min
Delan Azabani
Similarly, for a logarithmic scale, you'd use `log(items) / log(items in biggest tag) * (max - min) + min`. Conveniently enough, the base of your log does not matter.
Justin L.
I too would preferably use a logarithmic scale, otherwise if one tag is very popular, all the others will seem equal...
Matthieu M.