HTML 5 Flashcards

1
Q

basic html document

A

<!DOCTYPE html>

	Example 01

	This is my first document.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

XHTML Example

A

An HTML Document

Example
This is an example HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why XHTML document does not need to include the DOCTYPE

A

because XHTML documents that are delivered correctly using an XML MIME type and are processed as XML by browsers, are always rendered in no quirks mode. However, the DOCTYPE may optionally be included, and should be included if the document uses the compatible subset of markup that is conforming in both HTML and XHTML, and is ever expected to be used in text/html environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Metadata elements

A

appear within the head of a document. Some common examples of metadata elements include: title, meta, link, script and style.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

It is considered good practice to specify the primary language of the document on this element using the ____________ tag

A

<!DOCTYPE html>

...

...
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

xmlns attribute

A

In the XHTML syntax, the xmlns attribute needs to be specified on this element to declare that it is in the HTML namespace. You may use either the lang or xml:lang attribute to specify the langauge.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

base element (explanation)

A

specifying a base URL against which relative links will be resolved, and the name of the default target for opening links and form submissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

base element (example)

A
  • Notice that we have only specified a relative address

….

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

link element (explanation)

A

The link is for linking to other resources, such as stylesheets, favicons and syndication feeds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

embed style in document

A

<!--
...css goes here..
-->

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

embed java script in a document

A

My First Web Page

” + Date() + “

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

noscript element (explanation)

A

used to provide alternative content for users using browsers that do not support scripting or have it disabled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

noscript element (code)

A

Check out the current time:

World Time Server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

element attributes (list)

A
onbeforeunload
onerror
onhashchange
onload
onmessage
onoffline
ononline
onpopstate
onresize
onstorage
onunload
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Tag

A

WWF
The World Wide Fund for Nature (WWF) is….

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Tag

A

The tag defines a section of navigation links.

Not all links of a document must be in a element. The element is intended only for major block of navigation links.

Browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Tag

A

tag specifies independent, self-contained content.

An article should make sense on its own and it should be possible to distribute it independently from the rest of the site.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Tag

A

Epcot Center
The Epcot Center is a theme park in Disney World, Florida.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Tag

A

The tag specifies a header for a document or section.

The element should be used as a container for introductory content or set of navigational links.

You can have several elements in one document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Tag

A

tag defines a footer for a document or section.

A element should contain information about it’s containing element.

A footer typically contains the author of the document, copyright information, links to terms of use, contact information, etc.

You can have several elements in one document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Tag (explanation)

A

<!DOCTYPE html>

Written by Jon Doe.
Visit us at: Example.com
Box 564, Disneyland USA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Tag

A

tag is supported in all major browsers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Tag

A

represents the title of a work, such as an article, a book, a poem, a song, a film, or any other creative work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

, , , , , , and element

A

The , , , , , , and tags are all phrase tags. They are not deprecated, but it is possible to achieve richer effect with CSS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Tag

A

tag defines marked text.

Use the tag if you want to highlight parts of your text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

progress element (code)

Only in Firefox, Opera, Chrome

A

<!DOCTYPE html>

Downloading progress:

Note: The progress element is currently supported in Firefox, Opera, and Chrome.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q
meter element (code)
Chrome, Opera
A

<!DOCTYPE html>

2 out of 10
60%

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

code element (expl+code)

A

represents a fragment of computer code.

<!DOCTYPE html>

Computer code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

var element (expl+code)

A

represents a fragment of computer code.

<!DOCTYPE html>

variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

sample element (expl+code)

A

represents a fragment of computer code.

<!DOCTYPE html>

variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

HTML5 and Tags

A

<!DOCTYPE html>

This text contains subscript text.
This text contains superscript text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

HTML5 Tag (expl)

A

tag specifies a ruby annotation.

Ruby annotations are used for East Asian typography, to show the pronunciation of East Asian characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

html comment

A

<!-- Text here-->

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

HTML5 <!DOCTYPE> Declaration

A

The <!DOCTYPE> declaration must be the very first thing in your HTML5 document, before the tag.

The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

HTML5 Tag code

A

<!DOCTYPE html>

The WHO was founded in 1948.

The WHO was founded in 1948.
——————————————
By marking up abbreviations you can give useful information to browsers, spell checkers, translation systems and search-engine indexers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

HTML5 Tag (expl)

A

The tag defines an area inside an image-map (an image-map is an image with clickable areas).

The element is always nested inside a tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

HTML5 Tag (code)

A

<!DOCTYPE html>

Click on the sun or on one of the planets to watch it closer:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

HTML5 Tag

A

Your browser does not support the audio tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

HTML5 Tag

A

Click Me!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

The autofocus attribute is supported in all major browsers, except Internet Explorer and Opera.

A

The autofocus attribute is a boolean attribute.

When present, it specifies that a button should automatically get focus when the page loads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

disabled

A

Specifies that a button should be disabled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

The form attribute is supported in all major browsers, except Internet Explorer.

A

First name:
Last name:

Submit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

HTML5 formaction Attribute

A

First name:
Last name:
Submit
Submit as admin

A form with two submit buttons. The first submit button submits the form data to “demo_form.asp”, and the second submits to “demo_admin.asp”:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Not in Explorer

A

First name:
Last name:
Submit
Submit to a new window

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

HTML5 name Attribute

A

Choose your favorite subject:
HTML
CSS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

HTML5 type Attribute

A

A form with two buttons. One submit button and one reset button:
——————————————

First name:
Last name:
Submit
Reset

button - clickable button
submit - Default submits form-data
reset - button is a reset button (clears form-data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

HTML5 Tag code

A

<!DOCTYPE html>

Your browser does not support the canvas tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

HTML5 height & weight Attribute

A

specifies height and weight of the cavans

————————————-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

HTML5 Tag

A

The tag defines a table caption.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

HTML5 Tag

A

The tag specifies column properties for each column within a element.

<!DOCTYPE html>

ISBN Title
3476896 My first HTML
5869207 My first CSS

First column will bre read second yellow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

HTML5 Tag

A

The tag specifies a group of one or more columns in a table for formatting.

The tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

HTML5 Tag

A

The tag is used to group related elements in a form.

The tag draws a box around the related elements.

Tip: The tag defines a caption for the element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

HTML5 Tag

A

The tag defines a caption for a element.

The element can be placed as the first or last child of the element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

HTML5 Tag

A

The tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.

While the content of the element is related to the main flow, its position is independent of the main flow, and if removed it should not affect the flow of the document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

HTML5 Tag

A

The tag is used to create an HTML form for user input.

The  element can contain one or more of the following form elements:
 •
•
•
•
•
•
•
•
•
•
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

HTML5 Tag

A

The tag specifies an input field where the user can enter data.

elements are used within a element to declare input controls that allow users to input data.

An input field can vary in many ways, depending on the type attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

HTML5 width Attribute

A

The width attribute specifies the width of the element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

HTML5 value Attribute

A

The value attribute specifies the value of an element.

The value attribute is used differently for different input types:
•For “button”, “reset”, and “submit” - it defines the text on the button
•For “text”, “password”, “hidden” - it defines the initial (default) value of the input field
•For “checkbox”, “radio”, “image” - it defines the value associated with the input (this is also the value that is sent on submit)

Note: The value attribute is required with and .

Note: The value attribute cannot be used with .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Refresh document every 30 seconds

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

Define the last revision of your page:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Define a description of your web page:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Define keywords for search engines:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

HTML5 Tag

A

The tag specifies a header for a document or section.

The element should be used as a container for introductory content or set of navigational links.

You can have several elements in one document.

Note: A tag cannot be placed within a , or another element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

SVG Advantages

A

Advantages of using SVG over other image formats (like JPEG and GIF) are:
•SVG images can be created and edited with any text editor
•SVG images can be searched, indexed, scripted, and compressed
•SVG images are scalable
•SVG images can be printed with high quality at any resolution
•SVG images are zoomable (and the image can be zoomed without degradation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

What is SVG?

A
  • SVG stands for Scalable Vector Graphics
  • SVG is used to define vector-based graphics for the Web
  • SVG defines the graphics in XML format
  • SVG graphics do NOT lose any quality if they are zoomed or resized
  • Every element and every attribute in SVG files can be animated
  • SVG is a W3C recommendation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

Create a Canvas

A

Create a Canvas

A canvas is specified with the element.

Specify the id, width, and height of the element:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

What is Canvas?

A

element is used to draw graphics, on the fly, via scripting (usually JavaScript).

The element is only a container for graphics, you must use a script to actually draw the graphics.

A canvas is a drawable region defined in HTML code with height and width attributes.

Canvas has several methods for drawing paths, boxes, circles, characters, and adding images.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

code to make drag and drop

A

div1, #div2 {float:left; width:100px; height:35px; margin:10px;padding:10px;border:1px solid #aaaaaa;}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

event.preventDefault()

A

By default, data/elements cannot be dropped in other elements. To allow a drop, we must prevent the default handling of the element.

This is done by calling the event.preventDefault() method for the ondragover event:
event.preventDefault()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

Steps to make an element draggable

A

1) Make an Element Draggable
2) What to Drag - ondragstart and setData()
3) Where to Drop - ondragover
4) Do the Drop - ondrop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

Make an Element Draggable key to add to tag

A

First of all: To make an element draggable, set the draggable attribute to true:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

tag to prevent a page from being cached on users browser

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

opens the new document in a new window.

A

a new window

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

is

A

non breaking space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

What is the tag in HTML5 used for?

A

The tag is not supported in HTML5. Use the tag instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

Tag code

A

W3Schools

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

Tag explanation

A

tag specifies the base URL/target for all relative URLs in a document.

There can be at maximum one element in a document, and it must be inside the element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

currently supported only in Firefox and Chrome.

A

bdi stands for Bi-directional Isolation.

The tag isolates a part of text that might be formatted in a different direction from other text outside it.

This element is useful when embedding user-generated content with an unknown directionality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

all major browsers, except Internet Explorer.

A

The Word Break Opportunity () specifies where in a text it would be ok to add a line-break.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

Tag

A

The tag is supported in all major browsers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

Tag

A

The element is used to create a drop-down list.

Volvo
Saab
Opel
Audi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q

currently supported in Opera, Chrome, and Safari.

A

The autofocus attribute is a boolean attribute.

When present, it specifies that the drop-down list should automatically get focus when the page loads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q

disabled Attribute

A

The disabled attribute is a boolean attribute.

When present, it specifies that the drop-down list should be disabled.

A disabled drop-down list is unusable and un-clickable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q

all major browsers, except Internet Explorer.

A

The form attribute specifies one or more forms the drop-down list belongs to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

multiple Attribute

A

The multiple attribute is a boolean attribute.

When present, it specifies that multiple options can be selected at once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
86
Q

name Attribute

A

The name attribute specifies the name for a drop-down list.

Volvo
Saab
Opel
Audi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

size Attribute

A

Volvo
Saab
Opel
Audi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
88
Q

Tag

A

The tag is used to group inline-elements in a document.

The tag provides no visual change by itself.

The tag provides a way to add a hook to a part of a text or a part of a document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

Tag

A

The tag specifies text that is no longer correct, accurate or relevant by stricking it out.

The tag should not be used to define replaced or deleted text, use the tag to define replaced or deleted text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q

Tag

A

tag defines an explanation or pronunciation of characters (for East Asian typography) in a ruby annotation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
91
Q

Tag

A

tag defines what to show if a browser does NOT support ruby annotations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
92
Q

Tag

dir Attribute

A

ltr

Specifies left-to-right text direction

rtl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
93
Q

only supported by Internet Explorer 9.

A

The tag defines a command (a radiobutton, a checkbox, or a command button) that the user can invoke.

Save

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
94
Q

Tag

A

tag is used to describe an item in a definition list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
95
Q

Tag

A

same as

del> tag defines a text that has been deleted from a document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
96
Q

Tag

A

The tag defines a division or a section in an HTML document.

The tag is used to group block-elements and format them with CSS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
97
Q

Tag

A

tag defines an item in a definition list.
———————————-
tag is used in conjunction with (defines the definition list) and (describes the item in the list).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
98
Q

Tag

A

tag defines a container for an external application or interactive content (a plug-in).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
99
Q

height & weight Attribute

A

The height and weight attribute specifies the height adn weight of the embedded content, in pixels.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
100
Q

src Attribute

A

src attribute specifies the address of the external file to embed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
101
Q

type Attribute

A

The type attribute specifies the MIME type of the embedded content.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
102
Q

Tag

A

The tag is not supported in HTML5.

The tag was used to define one particular window (frame) within a frameset.

The and tags are not supported in HTML5, because they have a negative effect on the usability of a web page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
103
Q

Tag

A
HTML5 Tags
 <!-->
 <!DOCTYPE>
 <a>
 <abbr>
 <acronym>
 <address>
 <applet>
 <area>
 <article>
 <aside>
 <audio>
 <b>
 <base>
 <basefont>
 <bdi>
 <bdo>
 <big>
 <blockquote>
 <body>
 <br>
 <button>
 <canvas>
 <caption>
 <center>
 <cite>
 <code>
 <col>
 <colgroup>
 <command>
 <datalist>
 <dd>
 <del>
 <details>
 <dfn>
 <dir>
 <div>
 <dl>
 <dt>
 <em>
 <embed>
 <fieldset>
 <figcaption>
 <figure>
 <font>
 <footer>
 <form>
 <frame>
 <frameset>
 <h1> - <h6>
 <head>
 <header>
 <hgroup>
 <hr>
 <html>
 <i>
 <iframe>
 <img>
 <input>
 <ins>
 <keygen>
 <kbd>
 <label>
 <legend>
 <li>
 <link>
 <map>
 <mark>
 <menu>
 <meta>
 <meter>
 <nav>
 <noframes>
 <noscript>
 <object>
 <ol>
 <optgroup>
 <option>
 <output>
 <p>
 <param>
 <pre>
 <progress>
 <q>
 <rp>
 <rt>
 <ruby>
 <s>
 <samp>
 <script>
 <section>
 <select>
 <small>
 <source>
 <span>
 <strike>
 <strong>
 <style>
 <sub>
 <summary>
 <sup>
 <table>
 <tbody>
 <td>
 <textarea>
 <tfoot>
 <th>
 <thead>
 <time>
 <title>
 <tr>
 <track>
 <tt>
 <u>
 <ul>
 <var>
 <video>
 <wbr>

HTML5 <hgroup> Tag

Example

Use <hgroup> to group headings:

<hgroup>
<h1>Welcome to my WWF</h1>
<h2>For a living planet</h2>
</hgroup>

<p>The rest of the content...</p>

Browser Support

The <hgroup> tag is supported in all major browsers.

Definition and Usage

The <hgroup> tag is used to group heading elements.

The <hgroup> element is used to group a set of <h1> to <h6> elements, when a heading has multiple levels (subheadings).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
104
Q

Tag

A

The tag defines a thematic break in an HTML page (e.g. a shift of topic).

The element is used to separate content (or define a change) in an HTML page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
105
Q

Tag

A

tag defines a part of text in an alternate voice or mood. The tag is typically displayed in italic type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
106
Q

Tag

A

tag specifies an inline frame.

An inline frame is used to embed another document within the current HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
107
Q

name Attribute

A

The name attribute specifies a name for the .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
108
Q

height & weight Attribute

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
109
Q

src Attribute

A

The src attribute specifies the address of the document to embed in the inline frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
110
Q

Tag

A

tag specifies video, such as a movie clip or other video streams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
111
Q

autoplay Attribute

A

The autoplay attribute is a boolean attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
112
Q

height & weight Attribute

A

specifies the height and weight of the video

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
113
Q

loop Attribute

A

The loop attribute is a boolean attribute.

When present, it specifies that the video will start over again, every time it is finished.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
114
Q

all major browsers, except Internet Explorer and Safari.

A

The muted attribute is a boolean attribute.

When present, it specifies that the audio output of the video should be muted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
115
Q

poster Attribute

A

The poster attribute specifies an image to be shown while the video is downloading, or until the user hits the play button. If this is not included, the first frame of the video will be used instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
116
Q

preload Attribute

A

The preload attribute specifies if and how the author thinks that the video should be loaded when the page loads.

The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
117
Q

Tag

A

tag defines a row in an HTML table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
118
Q

Tag

A

The tag defines an ordered list.

Use the tag to define list items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
119
Q

Tag

A

tag is used to group header content in an HTML table.

The element is used in conjunction with the and elements to specify each part of a table (header, body, footer).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
120
Q

Tag

A

The tag defines a header cell in an HTML table.

An HTML table has two kinds of cells:

  • Header cells - contains header information (created with the element)
  • Standard cells - contains data (created with the element)

The text in elements are bold and centered by default.

The text in elements are regular and left-aligned by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
121
Q

scope Attribute

A

The scope attribute specifies whether a header cell is a header for a column, row, or group of columns or rows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
122
Q

rowspan Attribute

A

rowspan attribute defines the number of rows a header cell should span.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
123
Q

Tag

A

tag is supported in all major browsers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
124
Q

cols Attribute

A

The cols attribute specifies the visible width of a text area.

Tip: The size of a textarea can also be set by the CSS height and width properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
125
Q

disabled Attribute

A

The disabled attribute is a boolean attribute.

When present, it specifies that the text area should be disabled.

A disabled text area is unusable and the text is not selectable (cannot be copied).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
126
Q

form Attribute

A

The form attribute specifies one or more forms the text area belongs to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
127
Q

all major browsers, except Internet Explorer and Safari.

A

The required attribute is a boolean attribute.

When present, it specifies that a text area is required/must be filled out (in order to submit the form).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
128
Q

readonly Attribute

A

The readonly attribute is a boolean attribute.

When present, it specifies that a text area should be read-only.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
129
Q

wrap Attribute

A

The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
130
Q

Tag

A

The tag defines a standard cell in an HTML table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
131
Q

Tag

A

The tag is used to group the body content in an HTML table.

The element is used in conjunction with the and elements to specify each part of a table (body, header, footer).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
132
Q

Tag

A

The tag defines an HTML table.

An HTML table consists of the element and one or more , , and elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
133
Q

Tag

A

The tag is used to define style information for an HTML document.

Inside the element you specify how HTML elements should render in a browser.

Each HTML document can contain multiple tags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
134
Q

Tag

A

The tag is used to specify multiple media resources for media elements, such as and .

The tag allows you to specify alternative video/audio files which the browser may choose from, based on its media type or codec support.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
135
Q

Tag

A

Browsers often insert quotation marks around the quotation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
136
Q

Tag

A

tag defines preformatted text.

Text in a element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
137
Q

Tag

A

The tag is used to define parameters for plugins embedded with an element.

Tip: HTML 5 also includes two new elements for playing audio or video: The and tags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
138
Q

Tag

A

The tag defines an option in a select list.

The element goes inside a or element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
139
Q

Tag

A

The is used to group related options in a drop-down list.

If you have a long list of options, groups of related options are easier to handle for a user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
140
Q

Tag

A

The tag defines an embedded object within an HTML document. Use this element to embed multimedia (like audio, video, Java applets, ActiveX, PDF, and Flash) in your web pages.

You can also use the tag to embed another webpage into your HTML document.

You can use the tag to pass parameters to plugins that have been embedded with the tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
141
Q

Tagv

A

Not Supported in HTML5.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
142
Q

Tag

A

areas.

The name attribute of the element is associated with the ‘s usemap attribute and creates a relationship between the image and the map.

The element contains a number of elements, that defines the clickable areas in the image map.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
143
Q

Tag

A

The tag defines the relationship between a document and an external resource.

The tag is most used to link to style sheets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
144
Q

type Attribute

A

The type attribute specifies the MIME type of the linked document/resource.

This attribute is only used if the href attribute is set.

A very common MIME type for is “text/css”, which specifies a style sheet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
145
Q

rel Attribute

A

The required rel attribute specifies the relationship between the current document and the linked document/resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
146
Q

rel Attribute values 1

A
  • alternate - Links to an alternate version of the document (i.e. print page, translated or mirror)
  • author - Links to the author of the document
  • help - Links to a help document
  • icon - Imports an icon to represent the document
  • license - Links to copyright information for the document
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
147
Q

rel Attribute values 2

A
  • next - Indicates that the document is a part of a series, and that the next document in the series is the referenced document
  • prefetch - Specifies that the target resource should be cached
  • prev - Indicates that the document is a part of a series, and that the previous document in the series is the referenced document
  • search - Links to a search tool for the document
  • stylesheet - URL to a style sheet to import
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
148
Q

Tag

A

The tag defines a list item.

The tag is used in ordered lists(), unordered lists (), and in menu lists ().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
149
Q

Tag

A

The tag defines a caption for the , , and the elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
150
Q

Tag

A

tag defines a label for an element.

The element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the element, it toggles the control.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
151
Q

Tag

A

tag specifies a key-pair generator field used for forms.

When the form is submitted, the private key is stored locally, and the public key is sent to the server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
152
Q

Tag

A

tag defines a text that has been inserted into a document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
153
Q

Tag

A

The tag defines an image in an HTML page.

The tag has two required attributes: src and alt.

Note: Images are not technically inserted into an HTML page, images are linked to HTML pages. The tag creates a holding space for the referenced image.

Tip: To link an image to another document, simply nest the tag inside tags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
154
Q

Make an Element Draggable

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
155
Q

What to Drag - ondragstart

A

ondragstart attribute calls a function, drag(event), that specifies what data to be dragged.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
156
Q

method sets the data type and the value of the dragged data

A
function drag(ev)
{
ev.dataTransfer.setData("Text",ev.target.id);
 }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
157
Q

Where to Drop - ondragover

A

The ondragover event specifies where the dragged data can be dropped.

By default, data/elements cannot be dropped in other elements. To allow a drop, we must prevent the default handling of the element.

This is done by calling the event.preventDefault() method for the ondragover event:

event.preventDefault()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
158
Q

Do the Drop - ondrop

A

When the dragged data is dropped, a drop event occurs.

In the example above, the ondrop attribute calls a function, drop(event):

function drop(ev)
 {
 var data=ev.dataTransfer.getData("Text");
 ev.target.appendChild(document.getElementById(data));
 ev.preventDefault();
 }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
159
Q

draww lines in canvas code

A

<!DOCTYPE html>

Your browser does not support the canvas element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
160
Q

HTML5 Geolocation

A

HTML5 Geolocation API is used to get the geographical position of a user.

Since this can compromise user privacy, the position is not available unless the user approves it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
161
Q

method to get the user’s position

A

getCurrentPosition()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
162
Q

Geolocation error codes

A
  • Permission denied - The user did not allow Geolocation
  • Position unavailable - It is not possible to get the current location
  • Timeout - The operation timed out
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
163
Q

simple Geolocation example returning the latitude and longitude of the user’s position code

A

<!DOCTYPE html>
Click the button to get your coordinates:
Try It Longitude: “ + position.coords.longitude; }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
164
Q

display the result in a map, you need access to a map service that can use latitude and longitude, like Google Maps

A

<!DOCTYPE html>
Click the button to get your position:
Try It
“; }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
165
Q

getCurrentPosition() Method - Return Data

A

coords.latitude - The latitude as a decimal number
coords.longitude - The longitude as a decimal number
coords.accuracy - The accuracy of position
coords.altitude - The altitude in meters above the mean sea level
coords.altitudeAccuracy - he altitude accuracy of position
coords.heading - The heading as degrees clockwise from North
coords.speed - The speed in meters per second
timestamp - The date/time of the response

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
166
Q

watchPosition()

A

Returns the current position of the user and continues to return updated position as the user moves (like the GPS in a car).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
167
Q

clearWatch()

A

Stops the watchPosition() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
168
Q

What is HTML5 Web Storage?

A

With HTML5, web pages can store data locally within the user’s browser.

Earlier, this was done with cookies. However, Web Storage is more secure and faster. The data is not included with every server request, but used ONLY when asked for. It is also possible to store large amounts of data, without affecting the website’s performance.

The data is stored in key/value pairs, and a web page can only access data stored by itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
169
Q

localStorage

A

stores data with no expiration date

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
170
Q

sessionStorage

A

stores data for one session

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
171
Q

Before using web storage, check browser support for localStorage and sessionStorage:

A
if(typeof(Storage)!=="undefined")
   {
   // Yes! localStorage and sessionStorage support!
   // Some code.....
   }
 else
   {
   // Sorry! No web storage support..
   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
172
Q

localStorage Object note

A

localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
173
Q

sessionStorage Object notes

A

sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the browser window.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
174
Q

localStorage Object example set a local storage

A

<!DOCTYPE html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
175
Q

HTML5 Application Cache

all major browsers, except Internet Explorer.

A

HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection.

Application cache gives an application three advantages:

  1. Offline browsing - users can use the application when they’re offline
  2. Speed - cached resources load faster
  3. Reduced server load - the browser will only download updated/changed resources from the server
176
Q

Cache Manifest Basics:

How to enable?

A

to enable application cache, include the manifest attribute in the document’s tag:

<!DOCTYPE HTML>

177
Q

What is HTML5?

A

HTML5 will be the new standard for HTML.

The previous version of HTML, HTML 4.01, came in 1999. The web has changed a lot since then.

HTML5 is still a work in progress. However, the major browsers support many of the new HTML5 elements and APIs.

178
Q

How Did HTML5 Get Started?

A

HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).

WHATWG was working with web forms and applications, and W3C was working with XHTML 2.0. In 2006, they decided to cooperate and create a new version of HTML.

Some rules for HTML5 were established:

New features should be based on HTML, CSS, DOM, and JavaScript
Reduce the need for external plugins (like Flash)
Better error handling
More markup to replace scripting
HTML5 should be device independent
The development process should be visible to the public

179
Q

HTML5 - New Features

A

Some of the most interesting new features in HTML5:

The element for 2D drawing
The and elements for media playback
Support for local storage
New content-specific elements, like , , , ,
New form controls, like calendar, date, time, email, url, search

180
Q

Browser Support for HTML5

A

HTML5 is not yet an official standard, and no browsers have full HTML5 support.

But all major browsers (Safari, Chrome, Firefox, Opera, Internet Explorer) continue to add new HTML5 features to their latest versions

181
Q

HTML5 Video - How It Works

To show a video in HTML5, this is all you need:

A

Your browser does not support the video tag.

182
Q

HTML5 Tag

A
  • Defines a video or movie
  • Defines multiple media resources for media elements, such as and
  • Defines text tracks in mediaplayers
183
Q

HTML5 autoplay Attribute

A

A video that will automatically start playing:

Your browser does not support the video tag.

Note:The autoplay attribute is a boolean attribute, and can be set in the following ways:

184
Q

HTML5 controls Attribute

A

Note: The controls attribute is a boolean attribute, and can be set in the following ways:

185
Q

HTML5 height Attribute

A

Differences Between HTML 4.01 and HTML5

The tag is new in HTML5.

Syntax:

186
Q

HTML5 loop Attribute

A

The loop attribute is a boolean attribute.
When present, it specifies that the video will start over again, every time it is finished.
Syntax:

187
Q

HTML5 poster Attribute

A

The poster attribute specifies an image to be shown while the video is downloading, or until the user hits the play button. If this is not included, the first frame of the video will be used instead.

188
Q

HTML5 preload Attribute (no ie)

A

The preload attribute specifies if and how the author thinks that the video should be loaded when the page loads.
The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.
Note: The preload attribute is ignored if autoplay is present.

189
Q

HTML5 muted Attribute

muted attribute is supported in all major browsers, except Internet Explorer and Safari.

A

The muted attribute is a boolean attribute. When present, it specifies that the audio output of the video should be muted.

Note: The muted attribute is a boolean attribute, and can be set in the following ways:

190
Q

HTML5 src Attribute

A

Your browser does not support the video tag.

191
Q

HTML5 width Attribute

Note: Internet Explorer 8 and earlier versions, do not support the tag.

A

The width attribute is supported in all major browsers.

192
Q

HTML5 Video + DOM

A

The HTML5 element also has methods, properties, and events.

There are methods for playing, pausing, and loading, for example. There are properties (e.g. duration, volume, seeking) that you can read or set. There are also DOM events that can notify you, for example, when the element begins to play, is paused, is ended, etc.

The examples below illustrate, in a simple way, how to address a element, read and set properties, and call methods.

193
Q

HTML5 - Methods

A

play()
pause()
load()
canPlayType

194
Q

HTML5 - Properties

A
currentSrc
currrentTime
videoWidth
videoHeight
duration
ended
error
paused
muted
seeking
volume
height
width
195
Q

HTML5 - Events

A
play
oause
progress
error
timeupdate
ended
abort
empty
emptied
waiting
loadedmetadata
196
Q

Audio on the Web

A

Until now, there has not been a standard for playing audio files on a web page.
Today, most audio files are played through a plug-in (like flash). However, different browsers may have different plug-ins.
HTML5 defines a new element which specifies a standard way to embed an audio file on a web page: the element.

197
Q

HTML5 Audio - How It Works (code)

A

Your browser does not support the audio element.

198
Q

HTML5 Canvas

A

The element is used to draw graphics, on the fly, on a web page.

199
Q

What is Canvas?

A

The HTML5 element is used to draw graphics, on the fly, via scripting (usually JavaScript).

The element is only a container for graphics, you must use a script to actually draw the graphics.

A canvas is a drawable region defined in HTML code with height and width attributes.

Canvas has several methods for drawing paths, boxes, circles, characters, and adding images

200
Q

Draw With JavaScript

The element has no drawing abilities of its own.

All drawing must be done inside a JavaScript

A
201
Q

JavaScript uses the id to find the element

A

var c=document.getElementById(“myCanvas”);

202
Q

create a context object:

A

var ctx=c.getContext(“2d”);

203
Q

HTML5 Inline SVG

What is SVG?

A

SVG stands for Scalable Vector Graphics
SVG is used to define vector-based graphics for the Web
SVG defines the graphics in XML format
SVG graphics do NOT lose any quality if they are zoomed or resized
Every element and every attribute in SVG files can be animated
SVG is a W3C recommendation

204
Q

SVG Advantages

A

Advantages of using SVG over other image formats (like JPEG and GIF) are:

SVG images can be created and edited with any text editor
SVG images can be searched, indexed, scripted, and compressed
SVG images are scalable
SVG images can be printed with high quality at any resolution
SVG images are zoomable (and the image can be zoomed without degradation)

205
Q

Embed SVG Directly Into HTML Pages

A

<!DOCTYPE html>

206
Q

HTML5 - Using Geolocation

A

Longitude: “ + position.coords.longitude;

}

207
Q

HTML5 - Using Geolocation

Handling Errors and Rejections

A
function showError(error)   { 
  switch(error.code)     {
    case error.PERMISSION_DENIED:
      x.innerHTML="User denied the request for Geolocation."
      break;
    case error.POSITION_UNAVAILABLE:
      x.innerHTML="Location information is unavailable."
      break;
    case error.TIMEOUT:
      x.innerHTML="The request to get user location timed out."
      break;
    case error.UNKNOWN_ERROR:
      x.innerHTML="An unknown error occurred."
      break;     }   }
208
Q

Displaying the Result in a Map

A
function showPosition(position)
{
var latlon=position.coords.latitude+","+position.coords.longitude;
var img_url="http://maps.googleapis.com/maps/api/staticmap?center="
\+latlon+"&zoom=14&size=400x300&sensor=false";

document.getElementById(“mapholder”).innerHTML=””;
}

209
Q

getCurrentPosition() Method - Return Data

A

coords.latitude - The latitude as a decimal number
coords.longitude - The longitude as a decimal number
coords.accuracy - The accuracy of position
coords.altitude - The altitude in meters above the mean sea level
coords.altitude - Accuracy The altitude accuracy of position
coords.heading - The heading as degrees clockwise from North
coords.speed - The speed in meters per second
timestamp - The date/time of the response

210
Q

What is HTML5 Web Storage?

A

With HTML5, web pages can store data locally within the user’s browser.

Earlier, this was done with cookies. However, Web Storage is more secure and faster. The data is not included with every server request, but used ONLY when asked for. It is also possible to store large amounts of data, without affecting the website’s performance.

The data is stored in key/value pairs, and a web page can only access data stored by itself.

211
Q

localStorage and sessionStorage

A

There are two new objects for storing data on the client:

localStorage - stores data with no expiration date
sessionStorage - stores data for one session
Before using web storage, check browser support for localStorage and sessionStorage:

if(typeof(Storage)!=="undefined")   {
  // Yes! localStorage and sessionStorage support! 
  // Some code.....
  }
else   {
  // Sorry! No web storage support..
  }
212
Q

localStorage Object

A

The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year.

Example

localStorage.lastname=”Smith”;
document.getElementById(“result”).innerHTML=”Last name: “
+ localStorage.lastname;

213
Q

example counts the number of times a user has clicked a button. In this code the value string is converted to a number to be able to increase the counter:

A
if (localStorage.clickcount)
  {
  localStorage.clickcount=Number(localStorage.clickcount)+1;
  }
else
  {
  localStorage.clickcount=1;
  }
document.getElementById("result").innerHTML="You have clicked the button " + localStorage.clickcount + " time(s).";
214
Q

sessionStorage Object

A

if (sessionStorage.clickcount) { sessionStorage.clickcount=Number(sessionStorage.clickcount)+1;
} else {
sessionStorage.clickcount=1;
}
document.getElementById(“result”).innerHTML=”You have clicked the button “ + sessionStorage.clickcount + “ time(s) in this session.”;

215
Q

What is Application Cache?

Application cache is supported in all major browsers, except Internet Explorer.

A

HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection.

Application cache gives an application three advantages:

Offline browsing - users can use the application when they’re offline
Speed - cached resources load faster
Reduced server load - the browser will only download updated/changed resources from the server

216
Q

HTML5 Cache Manifest Example

Application cache is supported in all major browsers, except Internet Explorer.

A

<!DOCTYPE HTML>

The content of the document……

217
Q

Cache Manifest Basics

Every page with the manifest attribute specified will be cached when the user visits it. If the manifest attribute is not specified, the page will not be cached (unless the page is specified directly in the manifest file).

The recommended file extension for manifest files is: “.appcache”

A manifest file needs to be served with the correct MIME-type, which is “text/cache-manifest”. Must be configured on the web server.

A

218
Q

The Manifest File

A

The manifest file is a simple text file, which tells the browser what to cache (and what to never cache).

The manifest file has three sections:

CACHE MANIFEST - Files listed under this header will be cached after they are downloaded for the first time
NETWORK - Files listed under this header require a connection to the server, and will never be cached
FALLBACK - Files listed under this header specifies fallback pages if a page is inaccessible

219
Q

CACHE MANIFEST

A

The first line, CACHE MANIFEST, is required:

CACHE MANIFEST
/theme.css
/logo.gif
/main.js
The manifest file above lists three resources: a CSS file, a GIF image, and a JavaScript file. When the manifest file is loaded, the browser will download the three files from the root directory of the web site. Then, whenever the user is not connected to the internet, the resources will still be available
220
Q

NETWORK

A

The NETWORK section below specifies that the file “login.asp” should never be cached, and will not be available offline:

NETWORK:
login.asp
An asterisk can be used to indicate that all other resources/files require an internet connection:

NETWORK:
*

221
Q

FALLBACK

A

The FALLBACK section below specifies that “offline.html” will be served in place of all files in the /html5/ catalog, in case an internet connection cannot be established:

FALLBACK:
/html5/ /offline.html
Note: The first URI is the resource, the second is the fallback.

222
Q

Updating the Cache

A

Once an application is cached, it remains cached until one of the following happens:

The user clears the browser’s cache
The manifest file is modified (see tip below)
The application cache is programmatically updated

223
Q

Example - Complete Cache Manifest File

A
CACHE MANIFEST
# 2012-02-21 v1.0.0
/theme.css
/logo.gif
/main.js

NETWORK:
login.asp

FALLBACK:
/html5/
/offline.html

Tip: Lines starting with a “#” are comment lines, but can also serve another purpose. An application’s cache is only updated when its manifest file changes. If you edit an image or change a JavaScript function, those changes will not be re-cached. Updating the date and version in a comment line is one way to make the browser re-cache your files.

224
Q

Notes on Application Cache

A

Be careful with what you cache.

Once a file is cached, the browser will continue to show the cached version, even if you change the file on the server. To ensure the browser updates the cache, you need to change the manifest file.

Note: Browsers may have different size limits for cached data (some browsers have a 5MB limit per site).

225
Q

HTML5 Web Workers

A

When executing scripts in an HTML page, the page becomes unresponsive until the script is finished.

A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page. You can continue to do whatever you want: clicking, selecting things, etc., while the web worker runs in the background.

226
Q

Check Web Worker Support

A

Before creating a web worker, check whether the user’s browser supports it:

if(typeof(Worker)!=="undefined")
  {
  // Yes! Web worker support!
  // Some code.....
  }
else
  {
  // Sorry! No Web Worker support..
  }
227
Q

Create a Web Worker File

Now, let’s create our web worker in an external JavaScript.

Here, we create a script that counts. The script is stored in the “demo_workers.js” file

A

var i=0;

function timedCount() {
i=i+1;
postMessage(i);
setTimeout("timedCount()",500); }

timedCount();
The important part of the code above is the postMessage() method - which is used to posts a message back to the HTML page.

Note: Normally web workers are not used for such simple scripts, but for more CPU intensive tasks.

228
Q

Create a Web Worker Object

Now that we have the web worker file, we need to call it from an HTML page.

The following lines checks if the worker already exists, if not - it creates a new web worker object and runs the code in “demo_workers.js”:

A
if(typeof(w)=="undefined")
  {
  w=new Worker("demo_workers.js");
  }
Then we can send and receive messages from the web worker.

Add an “onmessage” event listener to the web worker.

w.onmessage=function(event){
document.getElementById(“result”).innerHTML=event.data;
};

229
Q

Terminate a Web Worker

A

When a web worker object is created, it will continue to listen for messages (even after the external script is finished) until it is terminated.

To terminate a web worker, and free browser/computer resources, use the terminate() method:

w.terminate();

230
Q

HTML5 Server-Sent Events

A

Server-Sent Events - One Way Messaging

A server-sent event is when a web page automatically gets updates from a server.

This was also possible before, but the web page would have to ask if any updates were available. With server-sent events, the updates come automatically.

Examples: Facebook/Twitter updates, stock price updates, news feeds, sport results, etc.

231
Q

Receive Server-Sent Event Notifications

The EventSource object is used to receive server-sent event notifications:

A
var source=new EventSource("demo_sse.php");
source.onmessage=function(event)
  {
  document.getElementById("result").innerHTML+=event.data + "";
  };
232
Q

Check Server-Sent Events Support

In the tryit example above there were some extra lines of code to check browser support for server-sent events:

A
if(typeof(EventSource)!=="undefined")
  {
  // Yes! Server-sent events support!
  // Some code.....
  }
else
  {
  // Sorry! No server-sent events support..
  }
233
Q

Server-Side Code Example

The server-side event stream syntax is simple. Set the “Content-Type” header to “text/event-stream”. Now you can start sending event streams.

Code in PHP (demo_sse.php):

A
234
Q

Server-Side Code Example

The server-side event stream syntax is simple. Set the “Content-Type” header to “text/event-stream”. Now you can start sending event streams.

Code in ASP (VB) (demo_sse.asp):

A
235
Q

The EventSource Object (list)

A

onopen - When a connection to the server is opened
onmessage - When a message is received
onerror - When an error occurs

236
Q

HTML5 Input Types

A
color
date
datetime
datetime-local
email
month
number
range
search
tel
time
url
week
237
Q

Input Type: color

A

<!DOCTYPE html>

Select your favorite color:

238
Q

Input Type: date

A

<!DOCTYPE html>

Birthday:

239
Q

Input Type: datetime

A

<!DOCTYPE html>

Birthday (date and time):

240
Q

Input Type: datetime-local

A

<!DOCTYPE html>

Birthday (date and time):

241
Q

Input Type: email

A

<!DOCTYPE html>

E-mail:

242
Q

Input Type: month

A

<!DOCTYPE html>

Birthday (month and year):

243
Q

Input Type: number

A

<!DOCTYPE html>

Quantity (between 1 and 5):

244
Q

Input Type: range

A

<!DOCTYPE html>

Points:

245
Q

Input Type: search

A

<!DOCTYPE html>

Search Google:

246
Q

Input Type: time

A

<!DOCTYPE html>

Select a time:

247
Q

Input Type: url

A

Add your homepage:

248
Q

Input Type: week.

The week type allows the user to select a week and year.

A

<!DOCTYPE html>

Select a week:

249
Q

HTML5 Tag

A

<!DOCTYPE html>

First name:
Last name:

250
Q

HTML5 New Form Elements

A

HTML5 has the following new form elements:

Note: Not all major browsers support all the new form elements. However, you can already start using them; If they are not supported, they will behave as regular text fields.

251
Q

HTML5 Element (exp)

A

he element specifies a list of pre-defined options for an element.

The element is used to provide an “autocomplete” feature on elements. Users will see a drop-down list of pre-defined options as they input data.

Use the element’s list attribute to bind it together with a element.

252
Q

HTML5 Element (code)

A
253
Q

HTML5 Element (code)

A

Username:

Encryption:

254
Q

HTML5 Element (expl)

A

The purpose of the element is to provide a secure way to authenticate users.

The tag specifies a key-pair generator field in a form.

When the form is submitted, two keys are generated, one private and one public.

The private key is stored locally, and the public key is sent to the server. The public key could be used to generate a client certificate to authenticate the user in the future.

255
Q

HTML5 Element

The element represents the result of a calculation (like one performed by a script).

A

<!DOCTYPE html>

0
100
+
=

256
Q

New attributes for :

A

autocomplete

novalidate

257
Q

New attributes for :

A
autocomplete
autofocus
form
formaction
formenctype
formmethod
formnovalidate
formtarget
height and width
list
min and max
multiple
pattern (regexp)
placeholder
required
step
258
Q

/ autocomplete Attribute (expl)

A

The autocomplete attribute specifies whether a form or input field should have autocomplete on or off.

When autocomplete is on, the browser automatically complete values based on values that the user has entered before.
Tip: It is possible to have autocomplete “on” for the form, and “off” for specific input fields, or vice versa.
Note: The autocomplete attribute works with and the following types: text, search, url, tel, email, password, datepickers, range, and color.

259
Q

/ autocomplete Attribute (code)

A

First name:
Last name:
E-mail:

260
Q

novalidate Attribute

The novalidate attribute is a boolean attribute.

When present, it specifies that the form-data (input) should not be validated when submitted.

A

E-mail:

261
Q

autofocus Attribute

The autofocus attribute is a boolean attribute.

When present, it specifies that an element should automatically get focus when the page loads.

A

<!DOCTYPE html>

First name:
Last name:

262
Q

form Attribute

The form attribute specifies one or more forms an element belongs to.

Tip: To refer to more than one form, use a space-separated list of form ids.

A

First name:

Last name:

263
Q

formaction Attribute

The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.

The formaction attribute overrides the action attribute of the element.

Note: The formaction attribute is used with type=”submit” and type=”image”.

A

First name:

Last name:

264
Q

formenctype Attribute

formenctype Attribute

A

First name:

265
Q

formmethod Attribute

The formmethod attribute defines the HTTP method for sending form-data to the action URL.

The formmethod attribute overrides the method attribute of the element.

Note: The formmethod attribute can be used with type=”submit” and type=”image”.

A

First name:

Last name:

266
Q

formnovalidate Attribute

The novalidate attribute is a boolean attribute.
When present, it specifies that the element should not be validated when submitted.
The formnovalidate attribute overrides the novalidate attribute of the element.
Note: The formnovalidate attribute can be used with type=”submit”.

A

E-mail:

267
Q

formtarget Attribute

The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.
The formtarget attribute overrides the target attribute of the element.
Note: The formtarget attribute can be used with type=”submit” and type=”image”.

A

First name:

Last name:

268
Q

height and width Attributes

The height and width attributes specify the height and width of an element.

Note: The height and width attributes are only used with .

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

A
269
Q

list Attribute

The list attribute refers to a element that contains pre-defined options for an element.

A
270
Q

min and max Attributes

The min and max attributes specify the minimum and maximum value for an element.

Note: The min and max attributes works with the following input types: number, range, date, datetime, datetime-local, month, time and week.

A

Enter a date before 1980-01-01:

Enter a date after 2000-01-01:

Quantity (between 1 and 5):

271
Q

multiple Attribute

The multiple attribute is a boolean attribute.

When present, it specifies that the user is allowed to enter more than one value in the element.

Note: The multiple attribute works with the following input types: email, and file.

A

Select images:

272
Q

pattern Attribute

The pattern attribute specifies a regular expression that the element’s value is checked against.
Note: The pattern attribute works with the following input types: text, search, url, tel, email, and password.
Tip: Use the global title attribute to describe the pattern to help the user.
Tip: Learn more about regular expressions in our JavaScript tutorial.

A

Country code:

273
Q

placeholder Attribute

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format).

The hint is displayed in the input field when it is empty, and disappears when the field gets focus.

Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.

A
274
Q

required Attribute

The required attribute is a boolean attribute.

When present, it specifies that an input field must be filled out before submitting the form.

Note: The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.

A

Username:

275
Q

step Attribute

The step attribute specifies the legal number intervals for an element.

Example: if step=”3”, legal numbers could be -3, 0, 3, 6, etc.

Tip: The step attribute can be used together with the max and min attributes to create a range of legal values.

Note: The step attribute works with the following input types: number, range, date, datetime, datetime-local, month, time and week.

A
276
Q

HTML5 contenteditable Attribute

A

The contenteditable attribute specifies whether the content of an element is editable or not.
This is an editable paragraph.
true - Specifies that the element is editable
false - Specifies that the element is not editable
inherit - Specifies that the element is editable if its parent is

277
Q

Window Event Attributes onafterprint

A

Script to be run after the document is printed

278
Q

Window Event Attributes

onbeforeprint

A

Script to be run before the document is printed

279
Q

Window Event Attributes

onbeforeonload

A

Script to be run before the document loads

280
Q

Window Event Attributes

onblur

A

Script to be run when the window loses focus

281
Q

Window Event Attributes

onerror

A

Script to be run when an error occur

282
Q

Window Event Attributes

onfocus

A

Script to be run when the window gets focus

283
Q

Window Event Attributes

onhaschange

A

Script to be run when the document has changed

284
Q

Window Event Attributes

onload

A

Script to be run when the document loads

285
Q

Window Event Attributes

onmessage

A

Script to be run when the message is triggered

286
Q

Window Event Attributes

onoffline

A

Script to be run when the document goes offline

287
Q

Window Event Attributes

ononline

A

Script to be run when the document comes online

288
Q

Window Event Attributes

onpagehide

A

Script to be run when the window is hidden

289
Q

Window Event Attributes

onpageshow

A

Script to be run when the window becomes visible

290
Q

Window Event Attributes

onpopstate

A

Script to be run when the window’s history changes

291
Q

Window Event Attributes

onredo

A

Script to be run when the document performs a redo

292
Q

Window Event Attributes

onresize

A

Script to be run when the window is resized

293
Q

Window Event Attributes

onstorage

A

Script to be run when a Web Storage area is updated

294
Q

Window Event Attributes

onundo

A

Script to be run when the document performs an undo

295
Q

Window Event Attributes

onunload

A

Script to be run when the user leaves the document

296
Q

Form Events onblur

A

Script to be run when an element loses focus

297
Q

Form Events onchange

A

Script to be run when an element changes

298
Q

Form Events oncontextmenu

A

Script to be run when a context menu is triggered

299
Q

Form Events onfocus

A

Script to be run when an element gets focus

300
Q

Form Events onformchange

A

Script to be run when a form changes

301
Q

Form Events onforminput

A

Script to be run when a form gets user input

302
Q

Form Events oninput

A

Script to be run when an element gets user input

303
Q

Form Events oninvalid

A

Script to be run when an element is invalid

304
Q

Form Events onselect

A

Script to be run when an element is selected

305
Q

Form Events onsubmit

A

Script to be run when a form is submitted

306
Q

Keyboard Events onkeydown

A

Script to be run when a key is pressed down

307
Q

Keyboard Events onkeypress

A

Script to be run when a key is pressed and released

308
Q

Keyboard Events onkeyup

A

Script to be run when a key is released

309
Q

Mouse Events onclick

A

Script to be run on a mouse click

310
Q

Mouse Events ondblclick

A

Script to be run on a mouse double-click

311
Q

Mouse Events ondrag

A

Script to be run when an element is dragged

312
Q

Mouse Events ondragend

A

Script to be run at the end of a drag operation

313
Q

Mouse Events ondragenter

A

Script to be run when an element has been dragged to a valid drop target

314
Q

Mouse Events ondragleave

A

Script to be run when an element leaves a valid drop target

315
Q

Mouse Events ondragover

A

Script to be run when an element is being dragged over a valid drop target

316
Q

Mouse Events ondragstart

A

Script to be run at the start of a drag operation

317
Q

Mouse Events ondrop

A

Script to be run when dragged element is being dropped

318
Q

Mouse Events onmousedown

A

Script to be run when a mouse button is pressed

319
Q

Mouse Events onmousemove

A

Script to be run when the mouse pointer moves

320
Q

Mouse Events onmouseout

A

Script to be run when the mouse pointer moves out of an element

321
Q

Mouse Events onmouseover

A

Script to be run when the mouse pointer moves over an element

322
Q

Mouse Events onmouseup

A

Script to be run when a mouse button is released

323
Q

Mouse Events onmousewheel

A

Script to be run when the mouse wheel is being rotated

324
Q

Mouse Events onscroll

A

Script to be run when an element’s scrollbar is being scrolled

325
Q

Media Events onabort

A

Script to be run on abort

326
Q

Media Events oncanplay

A

Script to be run when a file is ready to start playing (when it has buffered enough to begin)

327
Q

Media Events oncanplaythrough

A

Script to be run when a file can be played all the way to the end without pausing for buffering

328
Q

Media Events ondurationchange

A

Script to be run when the length of the media changes

329
Q

Media Events onemptied

A

Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)

330
Q

Media Events onended

A

Script to be run when the media has reach the end (a useful event for messages like “thanks for listening”)

331
Q

Media Events onerror

A

Script to be run when an error occurs when the file is being loaded

332
Q

Media Events onloadeddata

A

Script to be run when media data is loaded

333
Q

Media Events onloadedmetadata

A

Script to be run when meta data (like dimensions and duration) are loaded

334
Q

Media Events onloadstart

A

Script to be run just as the file begins to load before anything is actually loaded

335
Q

Media Events onpause

A

Script to be run when the media is paused either by the user or programmatically

336
Q

Media Events onplay

A

Script to be run when the media is ready to start playing

337
Q

Media Events onplaying

A

Script to be run when the media actually has started playing

338
Q

Media Events onratechange

A

Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)

339
Q

Media Events onreadystatechange

A

Script to be run each time the ready state changes (the ready state tracks the state of the media data)

340
Q

Media Events onseeked

A

Script to be run when the seeking attribute is set to false indicating that seeking has ended

341
Q

Media Events onseeking

A

Script to be run when the seeking attribute is set to true indicating that seeking is active

342
Q

Media Events onstalled

A

Script to be run when the browser is unable to fetch the media data for whatever reason

343
Q

Media Events onsuspend

A

Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason

344
Q

Media Events ontimeupdate

A

Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)

345
Q

Media Events onvolumechange

A

Script to be run each time the volume is changed which (includes setting the volume to “mute”)

346
Q

Media Events onwaiting

A

Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data)

347
Q

HTML5 Audio/Video DOM canPlayType() Method

The canPlayType() method checks if the browser can play the specified audio/video type.
The canPlayType() method can return one of the following values:

“probably” - the browser most likely supports this audio/video type
“maybe” - the browser might support this audio/video type
“” - (empty string) the browser does not support this audio/video type

A

myVid=document.createElement(‘video’);

isSupp=myVid.canPlayType(vidType+’;codecs=”‘+codType+’”’);

348
Q

HTML5 Audio/Video DOM load() Method

The load() method re-loads the audio/video element.

The load() method is used to update the audio/video element after changing the source or other settings.

A

document. getElementById(“mp4_src”).src=”movie.mp4”;
document. getElementById(“ogg_src”).src=”movie.ogg”;
document. getElementById(“video1”).load();

349
Q
HTML5 Audio/Video DOM play() Method
The play() method is supported in all major browsers.
A
var myVideo=document.getElementById("video1"); 
function playVid()
  { 
  myVideo.play(); 
  } 
function pauseVid()
  { 
  myVideo.pause(); 
  }
350
Q
HTML5 Audio/Video DOM pause() Method
The pause() method halts (pauses) the currently playing audio or video.
A
var myVideo=document.getElementById("video1"); 
function playVid()
  { 
  myVideo.play(); 
  } 
function pauseVid()
  { 
  myVideo.pause(); 
  }
351
Q

HTML5 Audio/Video DOM autoplay Property
The autoplay property is supported in all major browsers.

Note: This property is not supported in Internet Explorer 8 and earlier.

A

myVid=document.getElementById(“video1”);
myVid.autoplay=true;
myVid.load();

352
Q

HTML5 Audio/Video DOM buffered Property
The buffered property returns a TimeRanges object.

The TimeRanges object represents the user’s buffered ranges of the audio/video.

A buffered range is a time-range of buffered audio/video. The user gets several buffered ranges if he/she skips in the audio/video.

A

myVid=document.getElementById(“video1”);
alert(“Start: “ + myVid.buffered.start(0)
+ “ End: “ + myVid.buffered.end(0));

353
Q

HTML5 Audio/Video DOM controls Property

The controls property sets or returns if the browser should display standard audio/video controls.

Standard audio/video controls should include:

Play
Pause
Seeking
Volume
Fullscreen toggle (for video)
Captions/Subtitles (when available)
Track (when available)
A

myVid=document.getElementById(“video1”);

myVid.controls=true;

354
Q

HTML5 Audio/Video DOM currentSrc Property
The currentSrc property returns the URL of the current audio/video.

If no audio/video is set, an empty string is returned.

A

myVid=document.getElementById(“video1”);

alert(myVid.currentSrc);

355
Q

HTML5 Audio/Video DOM currentTime Property

The currentTime property sets or returns the current position (in seconds) of the audio/video playback.

When setting this property, the playback will jump to the specified position.

A

myVid=document.getElementById(“video1”);

myVid.currentTime=5;

356
Q

HTML5 Audio/Video DOM duration Property
The duration property returns the length of the current audio/video, in seconds.

If no audio/video is set, NaN (Not-a-Number) is returned.

A

myVid=document.getElementById(“video1”);

alert(myVid.duration);

357
Q

HTML5 Audio/Video DOM ended Property
The ended property returns if the playback of the audio/video has ended.
An audio/video has ended when the playback position is at the end of the audio/video.

A

myVid=document.getElementById(“video1”);

alert(myVid.ended);

358
Q

HTML5 Audio/Video DOM loop Property

The loop property sets or returns if the audio/video should start playing over again when it is finished.

A

myVid=document.getElementById(“video1”);

myVid.loop=true;

359
Q

HTML5 Audio/Video DOM muted Property

The muted property sets or returns if the audio/video should be muted (sound turned off).

A

Turn off sound for the video:
myVid=document.getElementById(“video1”);
myVid.muted=true;

360
Q

HTML5 Audio/Video DOM networkState Property

The networkState property returns the current network state (activity) of the audio/video.

A

Get the current network state of the video:
myVid=document.getElementById(“video1”);
alert(myVid.networkState);

361
Q

HTML5 Audio/Video DOM paused Property

The paused property returns if the audio/video is paused.

A

Check if the video is paused:
myVid=document.getElementById(“video1”);
alert(myVid.paused);

362
Q

HTML5 Audio/Video DOM preload Property
The preload property sets or returns if the audio/video should start loading as soon as the page loads.
The preload property allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.

A

myVid=document.getElementById(“video1”);

myVid.preload=”auto”;

363
Q

HTML5 Audio/Video DOM readyState Property
The readyState property returns the current ready state of the audio/video.
The ready state indicates if the audio/video is ready to play or not.

A

Get the current ready state of the video:
myVid=document.getElementById(“video1”);
alert(myVid.readyState);

364
Q

HTML5 Audio/Video DOM seekable Property
The seekable property returns a TimeRanges object.
The TimeRanges object represents ranges of the audio/video that are available for seeking for user.
A seekable range is a time-range of audio/video where the user can seek (move playback position) to.
For non-streaming videos it is often possible to seek anywhere in the video even before it has been buffered.

A

Get the first seekable range (part) of the video in seconds:

myVid=document.getElementById(“video1”);
alert(“Start: “ + myVid.seekable.start(0)
+ “ End: “ + myVid.seekable.end(0));

365
Q

HTML5 Audio/Video DOM seeking Property
The seeking property returns if the user is currently seeking in the audio/video.
Seeking is when you move/skip to a new position in the audio/video.

A

Show if the user is currently seeking in the video:
myVid=document.getElementById(“video1”);
document.getElementById(“span1”).innerHTML=(“Seeking: “ + myVid.seeking);

366
Q

HTML5 Audio/Video DOM src Property

The src property sets or returns the current source of the audio/video.

A

Change the source of the video:
myVid=document.getElementById(“video1”);
myVid.src=”movie.ogg”

367
Q

HTML5 Audio/Video DOM volume Property

The volume property sets or returns the current volume of the audio/video.

A

Set video volume to 20%:
myVid=document.getElementById(“video1”);
myVid.volume=0.2;

368
Q
HTML5 Audio/Video DOM canplay Event
The canplay event occurs when the browser can start playing the specified audio/video.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough
A

Alert that the video is ready to start playing:
myVid=document.getElementById(“video1”);
myVid.oncanplay=alert(“Can start playing video”);

369
Q

HTML5 Audio/Video DOM canplaythrough Event
Definition and Usage
The canplaythrough event occurs when the browser estimates it can play through the specified audio/video without having to stop for buffering.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough

A

Alert that the video can be played all the way through, without stopping:
myVid=document.getElementById(“video1”);
myVid.oncanplaythrough=alert(“Can play through video without stopping”);

370
Q

HTML5 Audio/Video DOM durationchange Event
The durationchange event occurs when the duration data of the specified audio/video is changed.
When an audio/video is loaded, the duration will change from “NaN” to the actual duration of the audio/video.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough

A

myVid=document.getElementById(“video1”);

myVid.ondurationchange=alert(“The video duration has changed”);

371
Q
HTML5 Audio/Video DOM loadeddata Event
The loadeddata event occurs when data for the current frame is loaded, but not enough data to play next frame of the specified audio/video.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough
A

Alert that data for the current frame is available:

myVid=document.getElementById(“video1”);
myVid.onloadeddata=alert(“Browser has loaded the current frame”);

372
Q

HTML5 Audio/Video DOM loadedmetadata Event
myVid=document.getElementById(“video1”);
myVid.onloadedmetadata=alert(“Meta data for video loaded”);

A

The loadedmetadata event occurs when meta data for the specified audio/video has been loaded.

Meta data for audio/video consists of: duration, dimensions (video only) and text tracks.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough
373
Q

HTML5 Audio/Video DOM loadstart Event
The loadstart event occurs when the browser starts looking for the specified audio/video. This is when the loading process starts.

During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough
A

Alert that the video is starting to load:

myVid=document.getElementById(“video1”);
myVid.onloadstart=alert(“Starting to load video”);

374
Q
HTML5 Audio/Video DOM progress Event
The progress event occurs when the browser is downloading the specified audio/video.
During the loading process of an audio/video, the following events occur, in this order:
loadstart
durationchange
loadedmetadata
loadeddata
progress
canplay
canplaythrough
A

myVid=document.getElementById(“video1”);

myVid.onprogress=alert(“Downloading video”);

375
Q

HTML5 canvas fillStyle Attribute

A
376
Q

HTML5 canvas strokeStyle Attribute

The strokeStyle attribute specifies the color of the selected drawing property.

A
377
Q

HTML5 canvas lineCap Attribute

The lineCap attribute specifies the “pencil cap” of the drawing property.

A
378
Q

HTML5 canvas lineJoin Attribute

The lineJoin attribute specifies how to display the corners when drawing lines.

A
379
Q

HTML5 canvas lineWidth Attribute

The lineWidth attribute specifies the width of the stroke of the selected drawing property.

A
380
Q

HTML5 canvas miterLimit Attribute

The miterLimit attribute works only if the lineJoin attribute is “miter”.

The miter is the distance between the inner corner and the outer corner in a line.

A
381
Q

HTML5 canvas shadowColor Attribute

The shadowColor attribute specifies the color of the shadow.
The shadow is adjusted by using the shadowOffsetX, shadowOffsetY, and the shadowBlur attributes.

A
382
Q

HTML5 canvas shadowOffsetX Attribute

The shadowOffsetX attribute specifies the left and right position of the shadow.

A
383
Q

HTML5 canvas shadowOffsetY Attribute

The shadowOffsetY attribute specifies the vertical position of the shadow.

A
384
Q

HTML5 canvas shadowBlur Attribute

A
385
Q

HTML5 canvas createLinearGradient Method

The createLinearGradient method creates a gradient object that changes from one color to another.
You can specify how and where these changes will take place, using the coordinate parameters.
The x0 and y0 parameters represents the start coordinates of the gradient.
The x1 and y1 parameters represents the end coordinates of the gradient.
Use the addColorStop() method to specify a color, and where to position the color in the gradient.
The gradient can be used to draw/fill rectangles, circles, lines etc.

A
386
Q

HTML5 canvas createPattern Method

The createPattern method uses an object to create a pattern to use on the canvas.

The object can be an image, a video, or another canvas element.

The pattern can be used to draw/fill rectangles, circles, lines etc.

A
387
Q

HTML5 canvas createRadialGradient Method

The createRadialGradient method creates a gradient object that makes a circle using the specified parameters.
The x0 and y0 represents the coordinates, of the start circle, where r0 represents the radius.
The x1 and y1 represents the coordinates of the end circle, where r1 represents the radius.
Use the addColorStop() method to specify a color, and where to position the color in the gradient.
The gradient can be used to draw/fill rectangles, circles, lines etc.

A

var canvas=document.getElementById(“myCanvas”);
var ctx=canvas.getContext(“2d”);
var grd=ctx.createRadialGradient(100,50,5,60,50,50);
grd.addColorStop(0,”red”);
grd.addColorStop(1,”white”);
ctx.fillStyle=grd;
ctx.fillRect(0,0,150,100);

388
Q

HTML5 canvas addColorStop Method

The addColorStop method specifies a color, and where to position the color in a gradient object.

The addColorStop method is used togheter with the createLinearGradient method or the createRadialrGradient.

A

var canvas=document.getElementById(“myCanvas”);
var ctx=canvas.getContext(“2d”);
var grd=ctx.createLinearGradient(0,0,150,0);
grd.addColorStop(0.3,”red”);
grd.addColorStop(0.7,”green”);
ctx.fillStyle=grd;
ctx.fillRect(0,0,150,100);

389
Q

HTML5 canvas fillRect Method

The fillRect method specifies a rectangle filled with a specified color.
Use the fillStyle attribute to specify a color, black is default and will be used if the fillStyle attribute is not specified.
The fillRect method takes four parameters (x,y,w,h).
The first two parameters represents the x and y coordinates of where to place the rectangle in the canvas.
The last two parameters represents the size (width and height) of the rectangle.

A
390
Q

HTML5 canvas strokeRect Method

The strokeRect method creates a rectangle.
Use the strokeStyle attribute to specify a color, black is default and will be used if the strokeStyle attribute is not specified.
The strokeRect method takes four parameters (x,y,w,h).
The first two parameters represents the x and y coordinates of where to place the rectangle in the canvas.
The last two parameters represents the size (width and height) of the rectangle.

A
391
Q

HTML5 canvas clearRect Method

The clearRect method clears all pixels inside the specified rectangle.
The clearRect method takes four parameters (x,y,w,h).
The first two parameters represents the x and y coordinates of where to begin erasing in the canvas.
The last two parameters represents the size (width and height) of the erasing rectangle.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.fillStyle="red";
ctx.fillRect(0,0,300,150);
 ctx.fillStyle="yellow";
ctx.fillRect(40,40,150,100);
 ctx.strokeRect(30,10,150,100);
ctx.clearRect(20,20,100,50);
392
Q

HTML5 canvas beginPath Method

The beginPath method clears the current path and specifies the beginning of a new path.
Use the moveTo(), lineTo(), quadricCurveTo, bezierCurveTo, arcTo, and arc(), to create paths.
Use the stroke() and fill() methods to draw the path on the canvas.

A
393
Q

HTML5 canvas moveTo Method

The moveTo method moves the path to the specified point in the canvas, without creating a line.
The moveTo method takes two parameters, the x an y coordinates.

Draw a path, shaped as the letter T:

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.beginPath();
ctx.moveTo(50,20);
ctx.lineTo(50,100);
 ctx.moveTo(20,20);
ctx.lineTo(80,20);
ctx.stroke();
394
Q

HTML5 canvas closePath Method

The closePath method draws a line from the path’s current point to the starting point.
Use the stroke() method to draw the path on the canvas.
Use the fill() method fill the path, the path will be filled with the color selected by the fillStyle attribute, black is default.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.beginPath();
ctx.moveTo(20,20);
ctx.lineTo(20,100);
 ctx.lineTo(70,100);
ctx.closePath();
ctx.stroke();
395
Q

HTML5 canvas lineTo Method

The lineTo method creates a line from the path’s current point to the specified point in the canvas.

The lineTo method takes two parameters, the x and y coordinates.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.beginPath();
ctx.moveTo(20,20);
ctx.lineTo(20,100);
 ctx.lineTo(70,100);
ctx.stroke();
396
Q

HTML5 canvas rect Method

The rect method creates a rectangle.
Use the stroke() or fill() methods to draw the rectangle on the canvas.
The rect method takes four parameters (x,y,w,h).
The first two parameters represents the x and y coordinates of where to place the rectangle in the canvas.
The last two parameters represents the size (width and height) of the rectangle.

A

var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
ctx.rect(20,20,150,100);
ctx.stroke();

397
Q

HTML5 canvas fill Method

The fill method fills the current path, with the color set by the fillStyle attribute, black is default.

If the current point is not the same as the start point, in the path, the fill method will complete the path by adding a line from the last point, to the startpoint of the path, like the closePath() method.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.rect(20,20,150,100);
 ctx.fillStyle="red";
 ctx.fill();
398
Q

HTML5 canvas stroke Method

The stroke method strokes the current path, with the color set by the strokeStyle attribute, black is default.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.moveTo(75,20);
 ctx.lineTo(20,20);
 ctx.lineTo(20,100);
 ctx.lineTo(75,100);
 ctx.moveTo(20,60);
 ctx.lineTo(60,60);
 ctx.strokeStyle="orange";
 ctx.stroke();
399
Q

HTML5 canvas clip Method

The clip method creates an area in the canvas, described with the different path methods, and this area is the only visible area in the canvas.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.rect(10,15,200,75);
ctx.clip();
ctx.fillStyle="lightblue";
 ctx.fillRect(0,0,300,150)
ctx.fillStyle="red";
ctx.font="30px Arial";
 ctx.fillText("Hello world", 10,30);
400
Q

HTML5 canvas quadraticCurveTo Method

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
 ctx.quadraticCurveTo(20,100,200,20);
ctx.stroke();
A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
 ctx.quadraticCurveTo(20,100,200,20);
ctx.stroke();
401
Q

HTML5 canvas bezierCurveTo Method

The bezierCurveTo method creates a line from the path’s current point to the specified point, via two controlpoints.

The bezierCurveTo method takes six parameters, the x and y coordinates for the first controlpoint, the x and y coordinates for the second controlpoint, and the x and y coordinates for the line’s destination.

A

var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
ctx.beginPath();
ctx.moveTo(20,20);
ctx.bezierCurveTo(20,100,200,100,200,20);
ctx.stroke();

402
Q

HTML5 canvas isPointInPath Method

The isPointInPath method returns a Boolean (true/false) value whether or not the specified point is in the current path.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.rect(20,20,150,100);
 if (ctx.isPointInPath(20,50))
    {
    ctx.stroke();
    };
403
Q

HTML5 canvas scale Method

The scale method scales the drawings, bigger or smaller.
You can scale the width or the height or both, by using the two parameters
If you scale both width and height two times (2,2) all drawings, from now on, will be twice as wide and twice as high as you specify
Also, the positioning will be scaled. If you scale (2,2), drawings will be positioned twice as far from the left, and top, of the canvas.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.strokeRect(5,5,25,15);
 ctx.scale(5,5);
 ctx.strokeRect(5,5,25,15);
404
Q

HTML5 canvas rotate Method

The rotate method rotates the canvas.

The rotation is done in an angle from the canvas’ position 0,0

A

var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
ctx.rotate(20*Math.PI/180);
ctx.fillRect(50,50,100,50);

405
Q

HTML5 canvas translate Method

The translate method moves the canvas to the given position.

The canvas itself will not change position, but all drawings done after the translate() method is moved

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
 ctx.fillRect(10,10,100,50);
 ctx.translate(70,70);
 ctx.fillRect(10,10,100,50);
406
Q

HTML5 canvas transform Method

The transform method uses a matrix to change the form of the canvas.
The transform method lets you scale, rotate, move, and skew the canvas.
The transformation will only affect drawings made after the transform method is called.
The transform method takes six parameters, representing the matrix.
The transform method behaves relatively to other transformations made by the rotate, scale, or translate methods. I.e. if you have allready set your drawing to scale by two, and the transform method scales your drawings by two, your drawings will now scale by four.
Tip: Check out the setTransform method, it does not behave relatively to other transformations.

A
407
Q

HTML5 canvas setTransform Method

The transform method uses a matrix to change the form of the canvas.
The transform method lets you scale, rotate, move, and skew the canvas.
The transformation will only affect drawings made after the transform method is called.
The transform method takes six parameters, representing the matrix.

A

ctx. font=”30px Arial”;
ctx. fillText(“Transform”,10,30);
ctx. setTransform(0.93,0.3,-0.3,0.93,0,0);
ctx. fillStyle=”lightblue”;
ctx. fillRect(0,0,250,100)

408
Q

HTML5 canvas font Attribute

The font attribute allows you to specify font properties of the text written on the canvas.

The font attribute uses the same syntax as the CSS font property.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.font="30px Arial";
ctx.fillText("Hello World",10,50);
409
Q

HTML5 canvas textAlign Attribute

The textAlign attribute is used to align text on the canvas.c
Use the fillText() or the strokeText() methods to place the text on the canvas.
The text will be aligned relatively from where you place the text.
If you place a text at position 150,75 and set textAlign=”right”, the text will end at position 150,75.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
 ctx.textAlign="right";
ctx.fillText("Hello World",150,75);
410
Q

HTML5 canvas textBaseline Attribute

The textBaseline attribute is used to vertically align text on the canvas.
Imagine there are lines running through the letters:
The fillText() and strokeText() methods will use these lines when positioning the text.
The different attributevalues will produce this output:

A

ctx. textBaseline=”bottom”;
ctx. fillText(“Bottom”,10,50);
ctx. textBaseline=”middle”;
ctx. fillText(“Middle”,97,50);
ctx. textBaseline=”top”;
ctx. fillText(“Top”,175,50);

411
Q

HTML5 canvas fillText Method

The fillText method specifies a text filled with a specified color.
Use the fillStyle attribute to specify a color, black is default and will be used if the fillStyle attribute is not specified.
The fillText method takes four parameters (text,x,y,maxWidth).
The first parameter represents the actual text.
The next two parameters represents the x and y coordinates of where to place the text on the canvas.
The last parameter is optional and represents the maximum width of the text, if the text is wider than the maxWidth the text will be displayd with a smaller font.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
ctx.font="30px Arial";
 ctx.fillText("Hello World",10,50);
412
Q

HTML5 canvas strokeText Method

The strokeText method species text on the canvas, drawn wit the specified color.
The strokeText method does not fill the letters with color, only the “borders”.
Use the strokeStyle attribute to specify a color, black is default and will be used if the strokeStyle attribute is not specified.
The strokeText method takes four parameters (text,x,y,maxWidth).
The first parameter represents the actual text.
The next two parameters represents the x and y coordinates of where to place the text on the canvas.
The last parameter is optional and represents the maximum width of the text, if the text is wider than the maxWidth the text will be displayd with a smaller font.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
ctx.font="30px Arial";
 ctx.strokeText("Hello World",10,50);
413
Q

HTML5 canvas measureText Method

The measureText method returns an object, with one attribute: width.

The width attribute returns the width of the text, in pixels.

Can be useful if you must know the width of a text before writing it on the canvas.

A

var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
var txt=”Hello World”
ctx.font=”30px Arial”;
ctx.fillText(“width:” + ctx.measureText(txt).width,10,50)
ctx.fillText(txt,10,100);

414
Q

HTML5 canvas imagedata width Attribute

The width attribute specifies the width of the imagedata object, in pixels.

A
var ctx=c.getContext("2d");
var imgData=ctx.createImageData(50,50);
for (i=0; i<imgData.width*imgData.height*4;i+=4)
  {
  imgData.data[i+0]=255;
  imgData.data[i+1]=0;
  imgData.data[i+2]=0;
  imgData.data[i+3]=255;
  }
 ctx.putImageData(imgData,10,10);
415
Q

HTML5 canvas imagedata height Attribute

The height attribute specifies the height of the imagedata object, in pixels.

A
ar ctx=c.getContext("2d");
var imgData=ctx.createImageData(50,50);
for (i=0; i<imgData.width*imgData.height*4;i+=4)
  {
  imgData.data[i+0]=255;
  imgData.data[i+1]=0;
  imgData.data[i+2]=0;
  imgData.data[i+3]=255;
  }
 ctx.putImageData(imgData,10,10);
416
Q

HTML5 canvas imagedata data Attribute

The data attribute represents an array containing information of every pixel of an imagedata object.

For every pixel in the imagedata object there are 4 pieces of information, the rgba values:

  1. The color red (0-255)
  2. The color green (0-255)
  3. The color blue (0-255)
  4. The alpha strength (0-255) where 0 is transparent and 255 is fully visible

The information is held in an array, and since the array contains 4 pieces of information of every pixel, the array’s size is 4 times the size of the rectangle: widthheight4.

You can change the information in the array, and put the new drawings back on the canvas, using the putImageData method.

A
var ctx=c.getContext("2d");
var imgData=ctx.createImageData(50,50);
for (i=0; i
417
Q

HTML5 canvas drawImage Method

The drawImage method is used when you want to use images on the canvas.
The drawImage method can also draw parts of an image, and/or increase/reduce the image size.
The drawImage method can take up to nine parameters, depending on what you want to do with the image.
The image object can be an image, a video, or another canvas element.

A
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("scream");
 ctx.drawImage(img,90,130,50,60,10,10,50,60);
418
Q

HTML5 canvas createImageData Method

The createImageData method specifies a new blank imagedata object.

All pixels of the new object has the default value transparent black, rgba(0,0,0,0).

The createImageData method can take two parameters which specifies the width and heigh.

The createImageData method can also take only one parameter, imgData, which will also create a new blank imagedata object where all the pixels are transparent black, but the width and height will be the same as the passed imageData object’s width and height.

For every pixel in the imagedata object there are 4 pieces of information, the rgba values:
1. The color red (0-255)
2. The color green (0-255)
3. The color blue (0-255)
4. The alpha strength (0-255) where 0 is transparent and 255 is fully visible
The information is held in an array, and since the array contains 4 pieces of information of every pixel, the array’s size is 4 times the size of the rectangle: widthheight4.
The array containing the information is stored in the .data property of the imagedata object.
You can change the information in the array, and put the new drawings back on the canvas, using the putImageData method.

A
var ctx=c.getContext("2d");
var imgData=ctx.createImageData(50,50);
for (i=0; i
419
Q

HTML5 canvas getImageData Method

The getImageData method creates a new imagedata object.
All pixels of the new imagedata object has the same rgba values as the specified parts of the canvas.
With the getImageData method you can read the pixels one by one.
The getImageData method takes four parameters, specifying a rectangle of the canvas (x,y,width,height).
The imagedata object is not a picture, it specifies a part (rectangle) of the canvas, and holds information of every pixel inside that rectangle.
For every pixel in the imagedata object there are 4 pieces of information, the rgba values:
1. The color red (0-255) 2. The color green (0-255) 3. The color blue (0-255) 4. The alpha strength (0-255) where 0 is invisible and 255 is fully visible
The information is held in an array, and since the array contains 4 pieces of information of every pixel, the array’s size is 4 times the size of the rectangle: widthheight4
The array containing the information is stored in the .data property of the imagedata object.
You can change the information in the array, and put the new drawings back onto the canvas, using the putImageData method.
Tip: For a demonstration of what you can do with the getImageData method, take a look at the example at the bottom of this page.

A
...
ctx.fillStyle="red";
ctx.fillRect(10,10,50,50);
var imgData=ctx.getImageData(30,30,50,50);
for (i=0; i
420
Q

HTML5 canvas putImageData Method

The putImageData method is used to put the data from an imagedata object onto the canvas.
The putImageData method can take three or seven parameters, three if the drawings should be the same size and shape as the imageData, and seven if you want to specify what part of the drawings that should be placed onto the canvas.
Read about the getImageData method, to learn how to manipulate the pixels.
Tip: For a demonstration of what you can do with the putImageData method, take a look at the example at the bottom of this page.

A
...
ctx.fillStyle="red";
ctx.fillRect(10,10,50,50);
var imgData=ctx.getImageData(30,30,50,50);
for (i=0; i
421
Q

HTML5 canvas globalAlpha Attribute

The globalAlpha attribute specifies the transparency of the drawings.
The globalAlpha attribute value can be a number between 0 and 1.
0=full transparency, 1=no transparency.

A
var c=document.getElementById("myCanvas");
 var ctx=c.getContext("2d");
ctx.fillStyle="red";
 ctx.fillRect(20,20,75,50);
ctx.fillStyle="blue"; 
ctx.globalAlpha=0.2;
 ctx.fillRect(50,50,75,50);
422
Q

tabindex attribute

Press the Tab key repeatedly on your keyboard
while on a web page, and you’ll see different page elements become highlighted

A

First Item Active
Third Item Active
Second Item Active

423
Q

code of how to get an element with id of “about-text”

A

document.getElementById(“about-text”)

424
Q

Hiding elements

A

Red Fox

Vulpes vulpes

425
Q

In HTML 4.01, the meta element looked like this

In HTML5 5, the meta element looks like this

A

4 –

5 –

426
Q

Microdata

A

uses a set of global attributes that may be used to add additional
semantic structure to the content on a page.

427
Q

No More Types for Scripts and Links

A

——HTML4—–

—–HTML5——

428
Q

how to make content of an element editable

A
  • Break mechanical cab driver.
    Drive to abandoned factory
  • Watch video of self
429
Q

Internet Explorer and HTML5

A

In order to ensure that the new HTML5 elements render correctly as block level elements, it’s necessary at this time to style them as such.

header, footer, article, section, nav, menu, hgroup {
display: block;
}
Unfortunately, Internet Explorer will still ignore these stylings, because it has no clue what, as an example, the header element even is. Luckily, there is an easy fix:

document. createElement(“article”);
document. createElement(“footer”);
document. createElement(“header”);
document. createElement(“hgroup”);
document. createElement(“nav”);
document. createElement(“menu”);

430
Q

Required Attribute

A
431
Q

Autofocus Attribute

A
432
Q

Regular Expressions

A

the new pattern attribute, we can insert a regular expression directly into our markup

Create a Username: 

Go
433
Q

Detect Support for Attributes

A
434
Q

semantic tags explanation old vs HTML5

A
semantics via distribution
, , , 
,,
semantics via HTML5
, , , , ,
435
Q

list HTML5 semantic tags

A
article
aside
figcaption
figure
footer
header
hgroup
mark
nav
section
time