The input tag should probably be generated before the label to allow nesting the input inside the label.