CIS195 Web Authoring 1: HTML

HTML Forms, Part 1

Topics by Week for the Ten-Week Term
1. Intro to HTML 6. Layout with CSS
2. More HTML, file paths 7. CSS Flexbox and Grid
3. Site structure and navigation 8. HTML Forms
4. Formatting with CSS 9. Multimedia
5. Midterm, Project Propposal 10. Tables, Project Completion
11. Final

 

Introduction

 

Purpose of forms

Forms allow users to enter data that can be processed by code that runs on the server (PHP, ASP.NET, Node.js, etc.). Input elements can be used by code that runs in the browser (JavaScript, WASM).

 

Basic Form Elements

Input element

The most common use of the input element is to enter textthis is the default use.

type attribute

Tye type attribute determines what kind of control will be shown in the browser. It has these possible values:

name attribute

This attribute defines the name of the field. It will be used in the name-value pair that is sent to the server.

value attribute

Use this to set a default value for an input element.

placeholder attribute

This attribute puts "watermark" text in an input element.

hidden attribute

This attribute makes an input element invisible.

 

Focus

When you click on a control, it's outline will become bolder or show in some way that it has been selected. This is called giving it focus. Using the tab key you can move from one control to the next in the form.

Terminology

Try it

Try it out on W3Schools

 

Fieldset and Legend Elements

The <fieldset. element groups a set of controls in a form by putting a box around them.

The <legend> element inserts a legend (aka title) into the box surrounding the fields.

 

Try it out on W3Schools

 

Label Element

Labels don't change the appearance of the form, but they:

Note: labels are in-line elements but, you can change them to a block element with the CSS display:block property.

Text Area Element

The <textarea> element allows users to enter multiple lines of text. The row and cols attributes determine the size. The wrap attribute determines the type of line warp: hard or soft.

 


Creative Commons License Web Authoring Lecture Notes by Brian Bird, 2017, revised 2023, is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.