Styling Forms with CSS – Part 3: Two-Column Form Layout
Inserting the Form Elements
In the following movie, you will add the form elements into each column and create the necessary CSS rules to style the elements. As in Part 1, you will also add Access Key and Tab Index navigation to enhance your users' experience when using your form.
You can begin by opening your TwoColFormLayout.html file in Code view.
Alternatively, you can complete the following steps:
- Open your HTML file in Design view.
- Delete the placeholder text in your Col1 div.
- Select the Text Field button from the Form tab/menu of the Insert bar. This opens the Input Tag Accessibility features.
- Type First into the Label box.
- For the Style option, select the Attach Label Using "for" Attribute option.
- For the Position option, select the Before Form Item option.
- Type a in the Access Key box and type 1 in the Tab Index box. Click OK.
- Press Shift+F11 to open the CSS panel.
- Click the New CSS Rule button to open the New CSS Rule dialog box.
- For the Selector Type, select the Tag radio button option.
- Select Label from the Tag pop-up menu and click OK. The Label Rule Definition dialog box opens.
- Select the Block category and select Block from the Display pop-up menu.
- Click OK. Note how the input is now forced down to the next line.
- Delete the placeholder text in your Col2 div.
- Select the Text Field button from the Insert bar. The Input Tag Accessibility features opens.
- Type Second into the Label field.
- For the Style option, select the Attach Label Using "for" Attribute option.
- For the Position option, select the Before Form Item option.
- Type b in the Access Key field and type 2 in the Tab Index field. Click OK.
- Place your cursor behind the input in Col1.
- Select the Text Field button from the Insert bar. The Input Tag Accessibility features opens.
- Type Third into the Label field.
- For the Style option, select the Attach Label Using "for" Attribute option.
- For the Position option, select the Before Form Item option.
- Type c in the Access Key field and type 3 in the Tab Index field. Click OK.
- Place your cursor behind the input in Col2.
- Select the Text Field button from the Insert bar. The Input Tag Accessibility features opens.
- Type Fourth into the Label field.
- For the Style option, select the Attach Label Using "for" Attribute radio button.
- For the Position option, select the Before Form Item radio button.
- Type d into the Access Key field and type 4 in the Tab Index field. Click OK.
- Place your cursor behind the second input in Col2.
- Select the Button button from the Insert bar. The Input Tag Accessibility features opens.
- Leave the Label box empty.
- For the Style option, select the Attach Label Using "for" Attribute option.
- For the Position option, select the Before Form Item option.
- Type e in the Access Key field and type 5 in the Tab Index field. Click OK.
- Press Shift+F11 to open the CSS panel.
- Select the
#formContainer rule.
- Select the 100 pop-up menu and change the 100 value to 65.
- Save your CSS file.
See how the form's width is reduced?