When putting a form on a webpage, I prefer the labels and edit boxes for all fields to be aligned, e.g. like this:

This is easily done by putting it all in a table. What is the best way to do this properly with CSS?
Note: I don't want to define fixed widths for certain columns or whatever. The width for the labels should just be automatically as much as necessary to fit the widest label.
I first thought to create two columns, one for the labels, one for the input fields. But then there is nothing that vertically aligns each label and its corresponding input field. So if one label has a <br> in it, or an input field is actually a selection with 3 radiobuttons above eachother, then I have to manually adjust the other column to keep everything in line (which is obviously a dumb method, and not even possible for dynamically generated content).

This is easily done by putting it all in a table. What is the best way to do this properly with CSS?
Note: I don't want to define fixed widths for certain columns or whatever. The width for the labels should just be automatically as much as necessary to fit the widest label.
I first thought to create two columns, one for the labels, one for the input fields. But then there is nothing that vertically aligns each label and its corresponding input field. So if one label has a <br> in it, or an input field is actually a selection with 3 radiobuttons above eachother, then I have to manually adjust the other column to keep everything in line (which is obviously a dumb method, and not even possible for dynamically generated content).
Comment