Documente Academic
Documente Profesional
Documente Cultură
Lecture Notes 3
Good Day Ladies and Gentlemen in this Lecture we are going to cover the following topics: HTML Mapping HTML Frames HTML Forms
Ensure that your Image will download at a regular speed. Image Map Shapes Shapes o Defines a shape for the clickable area. Possible values:default rect circle
Coords o
poly
Coordinates are specified as follows: o o o rect: left, top, right, bottom circle: center-x, center-y, radius poly: x1, y1, x2, y2, ...
Now let us look at an example <html> <head> <title>Untitled</title> </head> <body> <img src = "c:/images/jamaica_flag.gif" usemap = "#flag" alt=""> <map name = "flag"> <area shape = "rect" coords = "0,0,39,116" href = "http://www.cnn.com" alt = "http://ww.cnn.com"> <area shape = "rect" coords = "10,20,50,200" href = "http://www.msnbc.com" alt = "http://www.msnbc.com"> <area shape = "rect" coords = "51,201,100,400" href = "http://www.foxnews.com" alt = "http://www.foxnews.com"> </map> </body> </html>
HTML Frames
Frames allow users to display two or more pages at once on a webpage. It is also a great way of having a static navigation bar on a web page at all times, with the content displaying in another area of the page. Web page can have more than two frames. Please note that a container or frameset page contains no body.
Now let us look at an example <html> <head><title>Web Page Title</title></head> <frameset cols =25%, 75%> <frame src = menu.htm> <frame src = content.htm> </frameset> </html>
menu.htm
content.htm
<frameset rows = 50%,50%> <frame src = one.htm> <frame src = two.htm> </frameset> <frameset rows 50%, 50%> <frame src = three.htm> <frame src = four.htm> </frameset> </frameset>
The output below represents the results of when previewed in a Browser. One.htm Two.htm Three.htm Four.htm
Example
<frameset cols = 25%,*> <frame src = menu.htm name = menu frameborder="0"> <frame src = content.htm name = content frameborder="0"> </frameset>
<a href = index.htm target = content> If you want to open your frame in a completely new pop-up window use target = _blank. This is useful for linking to website other than yours (External links).
HTML Iframes
An iframe is used to display a web page within a web page. o Syntax for adding an iframe: <iframe src="URL"></iframe>
Iframe - Set Height and Width o The height and width attributes are used to specify the height and width of the iframe. The attribute values are specified in pixels by default, but they can also be in percent (like "80%"). Iframe - Remove the Border
The frameborder attribute specifies whether or not to display a border around the iframe. Set the attribute value to "0" to remove the border:
Example:
o <iframe src="demo_iframe.htm" frameborder="0"></iframe> Use iframe as a Target for a Link An iframe can be used as the target frame for a link. The target attribute of a link must refer to the name attribute of the iframe: o <iframe src="demo_iframe.htm" name="iframe_a"></iframe> <p><a href="http://www.cnn.com" target="iframe_a">CNN News</a></p>
HTML FORMS
Introduction to forms
An HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls.
Users generally "complete" a form by modifying its controls (entering text, selecting menu items, etc.), before submitting the form to an agent for processing (e.g., to a Web server, to a mail server, etc.)
Form Structure
Forms follow a specified structure. The form tag is a container. It holds all of the elements such as text boxes and submit buttons.
Submitting Forms
o After the form is completed it can be sent for processing by using the submit button.
Now lets examine forms sub-categories Single Line Text Boxes Text boxes allow users to either a line or multiple lines of text. The text box is suitable for Names, email Addresses etc. Password: <input type = password name = password> Text Area The textarea is allow multiple line of text to be entered. Its is suitable for comments, physical addresses (streets, roads). The browser will wrap each line of text automatically. E.g. <textarea cols = 25 rows = 60 name = Comments></textarea> HTML <fieldset> Tag E.g. <input type = text name = First Name Value = Enter First Name Here size = 25 maxlength = 30>
Example
o Group related elements in a form:
<form> <fieldset> <legend>Personalia:</legend> Name: <input type="text"><br> Email: <input type="text"><br> Date of birth: <input type="text"> </fieldset> </form>
Radio Buttons
These are small circular buttons that can be used collect polls or information that only require users to select one choice. o o E.g. <input type = radio name = gender value = M>Male <input type = radio name = gender value = F>Female
They should work like buttons on an old radio. Therefore the users should only be allowed to select one choice.
Check Boxes
Check boxes are grouped together and will allow users to make multiple selections. o E.g. <input type = checkbox name = payment method_1 value = CA>Cash <input type = checkbox name = payment method_2 value = DC>Debit Card <input type = checkbox name = payment method_3 value = CC>Credit Card
Most of the options available are not in view until the user gets intimate with the box and clicks on it.
The rest of the options will then pop-up below the box.
Reset Button
The Reset Button allow users to clear form of information entered before submitting. E.g. <input type = reset value = Reset Form>
HTML 5 - FORMS
New Form Elements
HTML5 offers new form elements, for more functionality: TagDescription: <datalist>Specifies a list of pre-defined options for input controls <keygen>Defines a key-pair generator field (for forms) <output>Defines the result of a calculation
HTML 5 DataList
<input list="browsers"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <option value="Chrome">
HTML 5 Keygen
Example A form with a keygen field: <form action="demo_keygen.asp" method="get"> Username: <input type="text" name="usr_name"> Encryption: <keygen name="security"> <input type="submit"> </form>
Example
o o Perform a calculation and show the result in an <output> element: <form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0 <input type="range" id="a" value="50">100 + <input type="number" id="b" value="50">= <output name="x" for="a b"></output> </form>
range search tel time url week HTML5 New Form Attributes HTML5 has several new attributes for <form> and <input>. New attributes for <form>: o o o o o o o o o autocomplete novalidate New attributes for <input>: autocomplete Autofocus form formaction formenctype formmethod