Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

css

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.

like image 918
Matteo Riva Avatar asked Apr 02 '10 16:04

Matteo Riva


2 Answers

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.

like image 53
Robusto Avatar answered Oct 20 '22 05:10

Robusto


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.

like image 25
Jaxidian Avatar answered Oct 20 '22 03:10

Jaxidian