However, there’s no doubt it looks a little messy with only the labels (and not the form elements) aligned horizontally. However, every solution I’ve tried to align the form elements neatly breaks two or more of my other specs. Any ideas?
If you want nice columns then you have to throw a width in somewhere to get them nicely aligned.
I would give a width to the label element and then align the text right so that is lines up nicely. If you make the label display:inline-block then you can also set vertical alignment nicely.
I personally would not use a list but as you have started I have used your structure and your names to complete this.
Of course there are loads of other methods but the inline-block avoids the problem with float clearing and float rising and the fact that you cant vertically align floats.
Dunno about others, but I’m totally mystified as to what you are asking here. The specifications listed above seem to contradict each other. What is the actual question? Ideally, could you do a page with just the form on it, as it’s very hard to test the version you linked to with all that other stuff on the page. I’m wondering if you are just asking for vertical-align: middle on the labels?
Sorry for the confusion. I’d like to horizontally align the form elements. The labels stack up in a nice column, perfect, just what I want. However, (as you’d expect) the form elements are inline and simply follow right after. While this isn’t awful, it’s not the sort of crisp-looking form that I prefer.
I would like the form elements to stack up in a nice column as well. My preference would be to have all the left edges aligned, but I would certainly accept aligning the right hand edges of the form elements compared to the rather ragged look that I have now.
I would like to do something like - float: right; on the form elements. However, this removes the form elements from the flow and they start poking outside the list items and interfering with the form elements (and labels) above and below them. (FYI if you’re looking at the test at http://www.earthchronicle.com/EC/Content/Computers/Programming/~OOCSSGallery.aspx#formListTest, the bright green border is applied to the ul, the dark green borders are the li elements, and the red border is the labels. I want to horizontally align the form elements but not if it means having them poke outside the dark green borders.)
If that’s all the explanation you needed, then great. Stop reading. Otherwise I will explain the specs in more detail.
I would prefer each label / form element set to be ordered with the label to the left of the form component. (I would entertain alternatives.)
Each set should not interfere with the sets above and below it. (e.g. I’ve tried using floats and positioning on the form elements to make them line up in a column, but since they’re removed from the flow of the page, they can screw up labels and form elements in other list items.)
I would like all the labels to make one column and all the form elements to make another (like the crisp designs people used to rely on tables for).
A ul element wraps the form elements. It’s set to float: left; so that it doesn’t expand to 100% width. Instead the ul snaps to the width of the longest label / form element set. I’ll happily entertain other ways of accomplishing that, but I don’t want to lose that behavior.
If you resize the width of the browser, the current behavior is for the text and form components to wrap neatly since everything is inline. I’ll happily entertain other ways of accomplishing that, but I don’t want to lose that behavior.
perhaps you’re looking for something like that. it’s only to make you an idea how to align labels and make two columns. i can make more improvements, but only if that is what you’re looking for.