开发者

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 usin开发者_运维知识库g 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.


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜