Steps to Create an HTML Form with KompoZer π¶
- Open KompoZer and Start a New HTML Page: π
- Launch KompoZer.
- Go to
File > Newπ or click the "New" button on the toolbar. - Shortcut:
Ctrl + N(Windows/Linux) orCmd + N(Mac) to create a new blank HTML document.
- Configure Page Title and Properties: β¨
- Go to
Format** > **Page Title and Properties**. **Shortcut:Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(Mac). - This will open the "Page Properties" dialog box, which contains several tabs. The "General" tab is where you'll find the most crucial metadata fields.
- In the "Page Properties" dialog, on the "General" tab, you'll see a field labeled "Title:".
- Enter your desired page title here. π·οΈ (e.g.,
My Awesome Product Page | MyCompany) - Enter your desired page author here. βοΈ (e.g.,
VD) - Click "OK". π
- Go to
- Save Your HTML File: πΎ
- Go to
File** > **Save**or click the "Save" button. **Shortcut:Ctrl + S(Windows/Linux) orCmd + S(Mac). - Save your HTML file by providing a related name without space & with a
.htmlextension (e.g.,userSignUp.html).
- Go to
- Insert the Form Element: π
- Place your cursor where you want the form to appear on your page.
- Go to **
Insert** > **Form** > **Define Form**. - The "Form Properties" dialog box will appear.
- Configure Form Properties: βοΈ
- Form Name: Give your form a descriptive name (e.g.,
"regForm", "contactForm", "registrationForm"). This is useful for JavaScript or for organizing multiple forms. - Action URL: This is the most important part. It's the URL of the script on your server that will process the form data when it's submitted. This could be a PHP, ASP, Python, Perl, or other server-side script. π»
- Example:
process_form.phporsubmit.asp
- Example:
- Method:
GET: Appends the form data to the URL as query parameters. Suitable for simple, non-sensitive data and when you want users to be able to bookmark the results. πPOST: Sends the form data in the body of the HTTP request. This is generally preferred for sensitive data (passwords, credit card numbers) or when sending large amounts of data, as it doesn't show in the URL. π
- Click "OK". π You'll see a dashed rectangle appear on your page, indicating the boundaries of your form.
- Form Name: Give your form a descriptive name (e.g.,
-
Insert a Table for Layout (Optional but Recommended): π
Before adding your fields, itβs a great idea to use a table. This keeps your labels (like "First Name") on the left and your input boxes on the right, perfectly aligned! π
- Place your cursor inside the dashed rectangle of your form.
- Go to Insert > Table. π±οΈ
- In the "Quick" tab, drag your mouse to select the number of rows and columns.
- Rows: However many fields you need (e.g., 5 or 6).
- Columns: Select 2 (one for the label, one for the input field).
- Adjust Table Look: Right-click the table and select Table Cell Properties, then click the Table tab. βοΈ
- Set Border to
0if you want the layout to be invisible. - Set Spacing to
5to give your fields some breathing room.
- Set Border to
- Click "OK". π
- Now, when you follow Step 6, type your labels in the left cells and insert your form fields in the right cells! βοΈ
- Add Form Elements (Input Fields, Text Areas, Buttons, etc.): β
Now you'll add the actual fields users will interact with.
- Text Input Fields: π‘
- Place your cursor inside the dashed form rectangle.
- Go to **
Insert** > **Form** > **Form Field** - In the "Form Field Properties" dialog:
- Field Type: Select
"**Text**" - Field Name: Give it a unique, descriptive name (e.g., "fname", "lname", "firstName", "email", "username"). This is how your server-side script will identify the data.
- Initial Value (Optional): To pre-populate the field with some text. π
- Max Length (Optional): Limit the number of characters. π
- Field Type: Select
- Click "OK". π
- Before or after adding the field, type a label next to it (e.g., "First Name:", "Email:") so users know what to enter. π§βπ»
- π‘ Remember to Test Your Changes! After adding or adjusting a textbox or its label (e.g., adding a space after the label), save your HTML file (Step 7) and open it in a web browser (Step 8) to ensure it appears as expected. Even small changes can impact the layout! π§
- Password Fields: π
- Similar to Text Input, but select
"Password"as the Field Type. Characters entered will be masked. π - π‘ Remember to Test Your Changes! After adding or adjusting a password box or its label (e.g., adding a space after the label), save your HTML file (Step 7) and open it in a web browser (Step 8) to ensure it appears as expected. Even small changes can impact the layout! π§
- Similar to Text Input, but select
- Text Areas (Multi-line Input): βοΈ
- Place your cursor inside the form.
- Go to **
Insert** > **Form** > **Textarea** - In the "Textarea Properties" dialog:
- Textarea Name: Unique name (e.g., "comments", "message").
- Rows: Number of visible rows. π
- Columns: Number of visible columns (width). βοΈ
- Click "OK". π
- π‘ Remember to Test Your Changes! After adding or adjusting a textarea or its label (e.g., adding a space after the label), save your HTML file (Step 8) and open it in a web browser (Step 8) to ensure it appears as expected. Even small changes can impact the layout! π§
- Checkboxes: β
- Place your cursor inside the form.
- Go to **
Insert** > **Form** > **Form Field** - Field Type: Select
"Checkbox" - Field Name: Name for the group of checkboxes (e.g., "interests").
- Field Value: The actual value sent to the server if this specific checkbox is checked (e.g., "sports", "reading").
- Initial State: Check "Checked" if you want it pre-selected. βοΈ
- Click "OK". π
- Type the label next to each checkbox (e.g., "Sports", "Reading"). ππ
- π‘ Remember to Test Your Changes! After adding or adjusting a checkbox or its label (e.g., adding a space after the label), save your HTML file (Step 8) and open it in a web browser (Step 8) to ensure it appears as expected. Even small changes can impact the layout! π§
- Radio Buttons: π
- Place your cursor inside the form.
- Go to **
Insert** > **Form** > **Form Field** - Field Type: Select
"Radio Button" - Field Name: Crucially, all radio buttons in a group must have the same Field Name (e.g., "gender", "paymentMethod"). π€
- Field Value: The unique value for this specific radio button (e.g., "male", "female", "creditCard", "paypal").
- Initial State: Check "Checked" if you want it pre-selected (only one in a group can be checked initially). βοΈ
- Click "OK". π
- Type the label next to each radio button (e.g., "Male", "Female"). π¨βπ¦°π©βπ¦°
- π‘ Remember to Test Your Changes! After adding or adjusting a radio button or its label, save your HTML file (Step 7) and open it in a web browser (Step 8) to ensure it appears and behaves correctly. π§
- Selection Lists (Dropdowns): π½
- Place your cursor inside the form.
- Go to **
Insert** > **Form** > **Selection List** - In the "Selection List Properties" dialog:
- List Name: Unique name (e.g., "country", "state").
- Multiple Selections Allowed: Check if users can select more than one option (hold
Ctrl/Cmdto select multiple). β - List Size: Number of visible options without scrolling. π’
- Click "Add Option..." for each item in your dropdown. β
- Option Text: What the user sees (e.g., "United States"). πΊπΈ
- Option Value: What is sent to the server (e.g., "USA").
- Initially Selected: Check if this option should be pre-selected. βοΈ
- Use the "Move Up" β¬οΈ and "Move Down" β¬οΈ buttons to reorder options.
- Click "OK". π
- π‘ Remember to Test Your Changes! After adding or adjusting a dropdown list, save your HTML file (Step 7) and open it in a web browser (Step 8) to ensure it displays and functions as intended. π§
- Submit Button: π
- Place your cursor inside the form.
- Go to **
Insert** > **Form** > **Form Field** - Field Type: Select
"Submit Button" - Field Name (Optional): Can be left blank or given a name if your script needs to identify the specific submit button used (less common).
- Field Value: The text that appears on the button (e.g., "Save", "Submit", "Send Message"). π¨
- Click "OK". π
- Reset Button: π
- Similar to Submit Button, but select
"Reset Button"as the Field Type. This button resets all form fields. π§Ή
- Similar to Submit Button, but select
- Save Your HTML File (Again!): πΎ
- After adding or changing any element, always go to
File** > **Save**or click the "Save" button to ensure your latest modifications are stored. This is crucial before testing! **Shortcut:Ctrl + S(Windows/Linux) orCmd + S(Mac). - Test Your Form (Locally): ππ§ͺ
- Open your saved HTML file in a web browser (you can usually double-click the
.htmlfile from your computer's file explorer). - Fill out the form and interact with all the fields you've added.
- Observe Carefully:
- Do all the labels appear correctly?
- Are fields aligned as you expect?
- Do checkboxes and radio buttons select/deselect properly?
- Does the dropdown list show all your options?
- Do spaces or other formatting appear as intended?
- If something looks wrong, go back to KompoZer, make the fix, and repeat steps 7 & 8! This cycle of "change, save, test" is fundamental to web development. π
- Important: Since you don't have a server-side script running locally, clicking "Submit" will likely result in a "File not found" π« or "Page not found" error if your "Action URL" points to a server-side script. This is normal. You're testing the front-end appearance and functionality of the form fields. β
Our Example¶
Form Name: regForm¶
| Field Labels | HTML Element | Type | Field Name | Field Value/s |
|---|---|---|---|---|
| First name | <input> |
text |
fname |
|
| Last name | <input> |
text |
lname |
|
<input> |
email |
email |
||
| Password | <input> |
password |
pass |
|
| Confirm Password | <input> |
password |
cpass |
|
| Mobile number | <input> |
number or text |
mob |
|
| Pin-code | <input> |
number or text |
pcode |
|
| Date of Birth | <input> |
date or text |
bdate |
|
| Hobbies | <input> |
checkbox |
hobby |
Reading , Writing, Singing, Dancing |
| Gender | <input> |
radio |
gen |
Male , Female, Others |
| City | <select> & <option> |
ct |
||
| Address | <textarea></textarea> |
|||
<input> |
submit |
submit |
submit |
|
<input> |
reset |
reset |
reset |