I am creating a horizontal legend in html/css. I have a colored box with some text next to it, then some space, then another colored box with some text, a space, etc.
[blue] - LabelA [green] - LabelB [red] - LabelC
I can’t figure out how to do this cross browser. I have tried all combinations of floating divs/spans I can think of, but either the label ends up going underneath the colored box or I can’t get padding to work to separate each key in the legend.
How would you do this?
You don’t need floats for this sort of thing. Really what you have is a list of pairs. There is a tag set for that called a definition list:
These are
inlineblockby default. From there you can style the pairs of elements like so: