Matteo Riva
Matteo Riva

Reputation: 25060

Why is giving a fixed width to a label an accepted behavior?

There are a lot of questions about formatting forms so that labels align, and almost all the answers which suggest a pure CSS solution (as opposed to using a table) provide a fixed width to the label element.

But isn't this mixing content and presentation? In order to choose the right width you basically have to see how big your longest label is and try a pixel width value until "it fits". This means that if you change your labels you also have to change your CSS.

Upvotes: 7

Views: 593

Answers (3)

fuxia
fuxia

Reputation: 63556

Fixed widths don’t have to be in pixels. em is a valid and better unit for containers with text.

Upvotes: 0

Robusto
Robusto

Reputation: 31883

I have no problem (Gasp! Heresy!) with using tables to line up form elements and their labels. If that makes me a Luddite, then so be it. I feel it can be argued that arrays of label/input pairs are sufficiently tabular to be rendered with tables.

Upvotes: 4

Jaxidian
Jaxidian

Reputation: 13511

Your labels can still word-wrap, thus allowing them to be very short or very long. You're not limiting your content in any way at all (almost), you're just dictating how they will be displayed.

Upvotes: 2

Related Questions