I’m trying to make input form where I have 4 inputs on different rows. I need to have 2 inputs on a row so then there will be only 2 rows.
I know I could do this by having them in 2 divs & setting one to float left & other to right but its a lot of HTML & I’ve always used tables for this as it was easier to have alternating row colors .
What is the right way to go about for forms & also this case? Thanks.
Regarding the markup; if using the LABEL element like that without the ‘for’ attribute for it to work (as intended) you must wrap the INPUT element itself. In otherwords to associate a label with another control ‘implicitly’, the control element must be within the contents of the LABEL element. The ‘for’ attribute associates a label with another control ‘explicitly’.
It is quite scalable the BR tag determines the number of columns per row, and you can have any # or rows you desire by merely adding to the mark up. Also it narrows down to one column. Additional CSS may be needed for OLD OLD versions of IE that do not support general sibling selectors,n which case you must add a class to alternate labels and inputs…::sigh old IE:::
Good method I often use breaks in forms as its cleaner than adding loads of divs and is one of the few places where breaks make sense. The only drawback is that you can’t colour rows unless you have divs around the rows which is why I used them in my example but usually I would have used a break to finish the line.
Great solution. 2 experts both given good solutions. This is a good place to meet the experts and for learning new tricks. I am excited to join this forum.
If i have to deal with this i can write the different code. These codes are working fine in IE7 and IE8 too.