Static Websites
This document discusses HTML5 forms and how to code them. It provides examples of different form field types like text, email, number and describes how to declare forms in HTML5 using tags. It also covers styling forms with CSS.
Static Websites
HTML 5
CSS
Forms
A demonstration of Form types in HTML 5 coding and styled with CSS
2.
Forms
• Forms arepart of a webpage that has multiple
controls that a user enters details in. These
controls include:
– Text fields
– Buttons
– Check boxes
– Colour pickers
3.
Declaring HTML5
• Todeclare the document type as HTML 5, the
code must start with the doctype tag
<!DOCTYPE HTML>
• The document also requires opening and
closing HTML tags
Opening: <HTML>
Closing: </HTML>
4.
Form Tags
• Todeclare a form, it requires opening and
closing form tags around the form controls.
Opening:<form>
Closing: </form>
5.
Different types ofForms
• Forms can be used on websites, for multiple
different reasons.
– Signing up for a social networking site
http://www.facebook.com/
– Online Banking
https://ib.nab.com.au/nabib/index.jsp
– Online Shopping
http://www.ebay.com.au/
– Registering for competitions
http://au.prime7.yahoo.com/a1/competitions/oliverf
ootwear/
6.
Browsers
The five mostcommonly used browsers are:
• Google Chrome
• Mozilla Firefox
• Internet Explorer
• Opera
• Safari
• Not all browsers recognise HTML5 tags. Look at
the bottom of each slide to see what browsers
recognise the form control being used.
7.
Labels
• A labelis a tag put in front or above a control
tag to identify what needs to be inserted into
the control field.
Opening: <label>
Closing: </label>
8.
Text Field
• Atext field has a default width of 20
characters and is a single line of text.
• A label needs to be placed before a text box to
identify what needs to be inserted.
Email
• The emailfield is new to HTML5. The field is
designed to accept an email address and will
display an error message if an email address is
not entered.
Checkboxes
• A checkboxallows the user to select multiple
boxes, depending on their preferences.
• Labels are needed to identify, the box being
selected.
Radio Buttons
• Aradio button is used when only one item is
needs to be selected out of a list of options.
19.
Radio Button Code
<inputtype = "radio"
name = "agree"
id = "agree"
value = "agree" />
<label for = "agree">Agree</label>
<input type = "radio"
name = "disagree"
id = "disagree"
value = "disagree" />
<label for = "disagree">Disagree</label>
20.
Submit Button
• Asubmit button is used for when a form
needs to be submitted. Submit buttons are
usually located at the bottom of the form.
• The default word on the button is “Submit”.
This can be changed to a specific word if
desired in the “value” area.
Validation & WebBrowsers
• A website must pass validation to be accessible.
• To validat code, the following websites can be
used.
– HTML: http://validator.w3.org/
– CSS: http://jigsaw.w3.org/css-validator/
• A website should also be made to work in
multiple Web Browsers
<br><br>
<label> Terms andConditions</label>
<br>
<input type = "radio"
name = "agree"
id = "agree"
value = "agree" />
<label for = "agree">Agree</label>
<input type = "radio"
name = "disagree"
id = "disagree"
value = "disagree" />
<label for = "disagree">Disagree</label>
CSS
• Cascading StyleSheets (CSS) is commonly used
for styling HTML code. CSS is usually done in a
seperate document and linked together with a
link placed in the HTML code.
HTML link to CSS sheet
<link rel="stylesheet" type="text/css"
href="assignmentCss.css" media="all" />
36.
• CSS iswhere all the colours and text styles are
selected.
• Borders can also be set in CSS.
• The section which needs to be styled, must be
declared at the top of the CSS page.
37.
• Background colours
• Border sizes
• Text
• Float
• Location of text
All of the above can be set in the
CSS code document