A professional contact form with multiple columns that demonstrates different layout techniques. You'll learn how to create responsive, well-organized forms using column widths and spacing.
Form layout is crucial for user experience. Well-organized forms are easier to fill out and look more professional. Column widths give you precise control over how your form fields are arranged.
Experiment with different width values to see how they affect the layout!
Let's start with a simple one-column layout. This is the foundation for building more complex multi-column forms.
Now let's create a two-column layout where one column is empty. This demonstrates how to use addEmpty() for spacing.
addEmpty() method creates invisible space that helps organize your form. It's perfect for creating visual separation between form sections. Now let's create a proper two-column layout with both columns containing fields. When you add multiple fields to the same row, they automatically share the available space equally.
Now let's use custom widths. The third parameter accepts CSS Grid units like 1fr, 2fr, 100px, or 50%.
2fr means "2 fractional units" - so the email field takes twice the space of the phone field. fr units are flexible and responsive. Let's combine different width units. Notice how we mix fr units with fixed px values for precise control.
100px are great for small fields like ZIP codes. fr units are perfect for flexible content like addresses. The third parameter controls the column width. Finally, let's add empty columns for visual spacing. addEmpty() creates invisible space that helps organize your form.
Now let's explore the most powerful feature: multi-column definitions like '1fr 1fr'. This allows a single field to span multiple columns, creating perfect alignment across rows.
'1fr 1fr' means "span two columns, each 1fr wide". This creates perfect alignment when combined with single-column fields in other rows. '1fr 1fr 1fr''2fr 1fr' and another with '1fr'Excellent! You've mastered multi-column layouts. Ready to explore selection fields?
Continue to Subforms TutorialOther learning paths: