BIM222 InternetProgramming Week5
BIM222 InternetProgramming Week5
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
1
3/30/21
HTML Blocks
§ Every HTML element has a default display value depending on what type
of element it is
§ The two display values are:
§ Block-Level Elements: A block-level element always starts on a new line and takes up the
full width available (stretches out to the left and right as far as it can)
<address> <article> <aside> <blockquote> <canvas> <dd> <div> <dl> <dt> <fieldset>
<figcaption> <figure> <footer> <form> <h1>-<h6> <header> <hr> <li> <main> <nav>
<noscript> <ol> <p> <pre> <section> <table> <tfoot> <ul> <video>
§ Inline Elements: An inline element does not start on a new line and only takes up as
much width as necessary
<a> <abbr> <acronym> <b> <bdo> <big> <br> <button> <cite> <code> <dfn>
<em> <i> <img> <input> <kbd> <label> <map> <object> <output> <q> <samp>
<script> <select> <small> <span> <strong> <sub> <sup> <textarea> <time> <tt> <var>
https://www.w3schools.com/html/html_blocks.asp
The <div> element is often used as a The <span> element is often used as
container for other HTML elements a container for some text
ü HTML5 replaces these definitions with more complex set of content categories -
Officially not part of HTML5, but still used
ü However, this distinction remains practical because it aligns well with existing CSS rules
2
3/30/21
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
3
3/30/21
Tag Description
Defines an article. The <article> element specifies independent, self-contained
content. An article should make sense on its own, and it should be possible to
<article> distribute it independently from the rest of the web site.
Examples of where an <article> element can be used: Forum post, blog post,
newspaper article
Defines some content aside from the content it is placed in (like a sidebar).
<aside> The <aside> content should be indirectly related to the surrounding content.
<details> Defines additional details that the user can view or hide
<figcaption> Defines a caption for a <figure> element
Specifies self-contained content, like illustrations, diagrams, photos, code
<figure> listings, etc.
Defines a footer for a document or section. A <footer> element typically
contains:
<footer>
authorship information, copyright information, contact information, sitemap,
back to top links, related documents
4
3/30/21
Tag Description
Specifies a header for a document or section. The <header> element represents
a container for introductory content or a set of navigational links.
<header>
A <header> element typically contains: one or more heading elements, logo or
icon, authorship information
<main> Specifies the main content of a document
<mark> Defines marked/highlighted text
<nav> Defines a set of navigation links
Defines a section in a document. “A section is a thematic grouping of content,
<section> typically with a heading.” A web page could normally be split into sections for
introduction, content, and contact information.
<summary> Defines a visible heading for a <details> element
<time> Defines a date/time
https://www.w3schools.com/html/html5_semantic_elements.asp
5
3/30/21
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
6
3/30/21
What is Multimedia?
§ Multimedia on the web is sound, music, videos, movies, and animations
§ Multimedia comes in many different formats
§ It can be almost anything you can hear or see, like images, music, sound, videos,
records, films, animations, and more
§ Web pages often contain multimedia elements of different types and formats
§ Browser Support
§ The first web browsers had support for text only, limited to a single font in a single
color
§ Later came browsers with support for colors, fonts, images, and multimedia!
§ Multimedia Formats
§ Multimedia elements (like audio or video) are stored in media files
§ The most common way to discover the type of a file, is to look at the file extension
§ Multimedia files have formats and different extensions like:
.wav, .mp3, .mp4, .mpg, .wmv, and .avi
7
3/30/21
§ Add style=“width:numberpx;height:numberpx;”
8
3/30/21
Notes on Images
§ In HTML 4.01, the width could be defined in pixels or in % of the
containing element
§ In HTML5, the value must be in pixels
§ Always specify the width and height of an image!
§ If width and height are not specified, the page might flicker while the image loads
§ Width and Height, or Style?
§ Both the width, height, and style attributes are valid in HTML5
§ However using the style attribute is suggested
§ It prevents styles sheets from changing the size of images
9
3/30/21
10
3/30/21
§ Example:
11
3/30/21
§ How it works?
§ The controls attribute adds audio controls, like play, pause, and volume
§ The <source> element allows you to specify alternative audio files which the
browser may choose from
§ The browser will use the first recognized format
§ The text between the <audio> and </audio> tags will only be displayed in
browsers that do not support the <audio> element
§ The type attribute specifies the media type File Format Media Type
§ type=“audio/mpeg”, type=“audio/ogg”, type=“audio/wav” MP3 audio/mpeg
OGG audio/ogg
WAV audio/wav
12
3/30/21
13
3/30/21
§ How it works?
§ The controls attribute adds video controls, like play, pause, and volume
§ The <source> element allows you to specify alternative video files which the
browser may choose from
§ The browser will use the first recognized format
§ The text between the <video> and </video> tags will only be displayed in
browsers that do not support the <video> element
14
3/30/21
§ The type attribute specifies the media type File Format Media Type
§ type=“video/mp4”, type=“video/ogg”, type=“video/webm” MP4 video/mp4
OGG video/ogg
WebM video/webm
15
3/30/21
16
3/30/21
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
17
3/30/21
HTML Forms
§ Forms are a great way to let you give people
the opportunity to send you feedback
§ Forms let us send additional information
§ Forms are used to collect user input, or pass
data
§ How they can do that?
§ They let us put in different type of input
elements, i.e. strings, numbers, files, etc.
§ Forms must have server with them
§ The user input is most often sent to a server
for processing
HTML Forms
§ Forms add a new layer to the Request-Response Cycle
18
3/30/21
Web Development
§ Front-end
§ What happens on the browser/client-side
§ How we want things to look on your laptop, on your phone, on your tablet
§ We do this using HTML, CSS, JavaScript
§ Back-end
§ What the server is handling
§ Python, Ruby, PHP, Perl, Java
HTML Forms
§ The HTML <form> element defines a form that is used to collect user
inputs
19
3/30/21
<textarea>
form
elements <input type=“submit”>
20
3/30/21
or
21
3/30/21
GET or POST
method=“get”
get is the default method
Note: GET must NOT be used when sending sensitive information! GET is
best suited for short, non-sensitive, amounts of data, because it has size
limitations too!
22
3/30/21
Note: Always use POST if the form data contains sensitive or personal
information. POST has no size limitations, and can be used to send large
amounts of data
23
3/30/21
24
3/30/21
More on Forms:
Form Elements have Different Attributes
§ Form elements can have the following three attributes (most common)
§ type
§ name
§ id
Attributes
§ name
§ Almost all input types should have a name attribute associated with it, in order
to be submitted
§ Because that is the information sent to the server
§ If the name attribute is omitted, the data of that input field will not be sent at all
§ Very important for back-end development (on the server side)
§ The name attribute is assigned whatever value is input by the user
§ id
§ Very important for front-end development
§ Used for labels
§ Identifies particular part of the form
§ So, you can make sure that when you click on the label, the right input value will be
highlighted
§ Used by JavaScript
25
3/30/21
Additional Attributes
§ value
§ A value attribute does different things depending upon which input type it's
matched with
§ button: text inside the button
§ textfield: provides a default value
§ If not changed, will be the value passed to the server
§ placeholder
§ Similar to value, but instead, it provides a suggestion
§ It is not an “official” value, just something you may want to do
§ In telephone numbers or anything where you want people to format things in a certain way
§ In the telephone field à (123) 456-7890
§ It's a suggestion
§ It's letting the person know what kind of input you're expecting
§ As soon as somebody clicks in there, it's gone, so it's not permanent
Useful Attributes
§ required
§ Halts the submit process if any of the required elements are empty
§ Essentially says, hey, you can't submit this form if this particular input field is empty
Ex: If you want someone to put in their password, you need to include required
Else, people can just leave it empty, submit the forms without adding password
§ pattern
§ Only works with input type=text and requires the input have a specific format
§ [0-9]{5} à You can only enter in numbers and there has to be five of them
§ [0-9]{13-16} à You can only enter in numbers, but they need to be between 13 and 16
“Regular
Expressions” § [a-zA-Z]+ à You can only enter characters, which can be in lowercase a to z, or upper
case A to Z. And plus means, there has to be at least one character.
§ Best way is use the pattern attribute with placeholder and supporting text to let people
know the format they need to use
26
3/30/21
Useful Attributes
§ size=“something” à specifies the size (in characters) for the input field
§ autofocus à sets which field is given focus at the start
§ autocomplete=“on/off” à specifies whether a form or input field
should have autocomplete on or off
§ When autocomplete is on, the browser automatically complete the input values
based on values that the user has entered before
§ min, max, and step can place limits on number inputs
§ min à You can't enter a number that's less than 3
§ max à You can't enter a number over 100
§ step à You can only enter in increments of 5, or increments of 10
27
3/30/21
Example: Password
What is
WRONG?
28
3/30/21
29
3/30/21
FIREFOX
30
3/30/21
31
3/30/21
32
3/30/21
33
3/30/21
Example
34
3/30/21
Example
Element Grouping
35
3/30/21
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
36
3/30/21
Outline
§ HTML Blocks § HTML Forms
§ Block-Level Elements § HTML Form Basics
§ Inline Elements § More on Forms
§ Handling File Upload
§ HTML 5 Semantics § Some New HTML5 Input Elements
§ What are semantic elements? § Grouping
§ New semantic elements in HTML5
§ HTML vs. HTML5
§ Inspect the DOM with Chrome
§ HTML Multimedia § Tips: Layout & Design
§ Images
§ Audio
§ Video
37
3/30/21
§ The Bad
38
3/30/21
Tips: Layout
39
3/30/21
Wireframing
https://www.lucidchart.com/pages/landing/wireframe_tool?utm_source=google&utm_medium=cpc&utm_campaign=wiref
raming_poland&gclid=CjwKEAiAxKrFBRDm25f60OegtwwSJABgEC-Z3aKB1VU_u4GfGyEmWBumIp90WQqRC--
guseHYg9bNRoC7tzw_wcB
Mockup
§ A storyboard that steps through a mock user experience that details
significant expected behaviors both from a user interface and
application semantic
§ Not just wire frames
§ a walk through
§ wire frames / UI mockups can be included
§ but digs a bit deeper and describes the value proposition for the user
§ Some popular mockup tools
§ https://www.uxpin.com/
§ https://moqups.com/
§ https://balsamiq.com/products/mockups/
40
3/30/21
Navigational Structure
41