1. Trang chủ
  2. » Công Nghệ Thông Tin

Tổng quan lập trình HTML 5

69 176 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 69
Dung lượng 9,25 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos... HTML5 Audio• Example: Your browser does not support the element...

Trang 2

HTML5 = HTML + CSS + JS API

Trang 4

New and Updated HTML5 Elements

HTML5 introduces 28 new elements:

<section>, <article>, <aside>, <hgroup>,

<header>,<footer>, <nav>,

<figure>, <figcaption>, <video>, <audio>,

<source>, <embed>, <mark>,<progress>,

<meter>, <time>, <ruby>, <rt>, <rp>,<wbr>,

<canvas>, <command>, <details>,<summary>,

<datalist>, <keygen> and <output>

4

Trang 5

HTML5 Structure

5

Trang 6

Structure

Trang 8

Lets put altogether

8

Trang 10

• The section element represents a generic section

of a document or application A section, in this context, is a thematic grouping of content,

typically with a heading

Trang 11

• A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required The

header element can also be used to wrap a

section's table of contents, a search form, or any relevant logos

Trang 13

• The footer element represents a footer for its nearest ancestor sectioning content or

sectioning root element A footer typically

contains information about its section such as who wrote it, links to related documents,

copyright data, and the like

Trang 14

• The article element represents a self-contained

composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g in syndication This could be a forum post,

a magazine or newspaper article, a blog entry, a submitted comment, an interactive widget or gadget, or any other independent item of content

Trang 15

• The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links

Trang 16

Block semantic element

• <aside>

• <figure>

Trang 17

that content Such sections are often

represented as sidebars in printed typography.

Trang 18

• Specifies self-contained content, like illustrations, diagrams, photos, code listings, etc

Trang 19

Inline semantic element

• <mark>

• <time>

• <meter>

• <progress>

Trang 20

• Defines marked/highlighted text

Trang 21

• Defines a date/time

Trang 22

• Defines a scalar measurement within a known range (a gauge)

Trang 23

• The progress element provides a simple and

effective way for a web designer to notify a user

of their progress regarding a specified task

Trang 24

HTML Audio/Video

24

Trang 26

Ebook for HTML5 Media

Audio/Video

Trang 27

HTML5 in Action on the Web

Trang 28

<param name="movie" value="movie.swf">

<param name="quality" value="high">

<param name="menu" value="true">

<param name="LOOP" value="false">

</object>

CODEC == COmpressor/DECompressor

Trang 29

Support for (and demo of) HTML5 Audio

• http://caniuse.com/audio

• http://beta.theexpressiveweb.com/#!/html5-audio

Trang 30

Format IE 9 Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0

Trang 31

Support for (and demo of) HTML5 Video

• HTML5 Video

– http://caniuse.com/video

– http://beta.theexpressiveweb.com/#!/html5-video

Trang 32

Format IE Firefox Opera Chrome Safari

MPEG 4 9.0+ No No 5.0+ 3.0+ WebM No 4.0+ 10.6+ 6.0+ No

Trang 33

Audio/Video for Publishers

HTML5 lets you embed audio/video directly in your content without any plugins needed:

<audio id="new_slang">

<source src="new_slang.wav" type="audio/wav"/>

<source src="new_slang.mp3" type="audio/mp3"/>

<source src="new_slang.ogg" type="audio/ogg"/>

<em>(Sorry, &lt;audio&gt; element not supported in your

browser/ereader, so you will not be able to listen to this song.)</em>

</audio>

<video id="dancing_pony" width="300" height="300">

<source src="dancing_pony.mp4" type="video/mp4"/>

<source src="dancing_pony.ogg" type="video/ogg"/>

<em>(Sorry, &lt;video&gt; element not supported in your

browser/ereader, so you will not be able to watch this video.)</em>

</video>

Trang 35

HTML5 Audio

• Example:

<audio src=" foo.wav " controls autoplay>

Your browser does not support the <audio> element.

</audio>

• Property:

– src, autoplay, controls – loop, autobuffer, preload

Trang 36

Handling Media Events

Event Description

abort This event is generated when playback is aborted canplay This event is generated when enough data is

available that the media can be played.

ended This event is generated when playback completes error This event is generated when an error occurs.

loadeddataThis event is generated when the first frame of

the media has finished loading.

loadstart This event is generated when loading of the media

begins.

Trang 37

Handling Media Events

Event Description

pause This event is generated when playback is paused.

play This event is generated when playback starts or

resumes.

progress This event is generated periodically to inform the

progress of the downloading the media.

ratechange This event is generated when the playback speed

changes.

seeked This event is generated when a seek operation

completes.

Trang 38

Handling Media Events

waiting This event is generated when the requested

operation (such as playback) is delayed pending the completion of another operation (such as a seek).

Trang 39

<audio id="audio" controls>

<source src="orion.ogg" type="audio/ogg" />

</audio>

var clip = document.getElementById('audio');

clip.muted = false; //câm

clip.play(); //phát

clip.pause(); //tạm dừng

39

Trang 40

Learning by example

• Prepare video and audio file

• http://html5media.info/

Trang 41

HTML5/CSS3

HTML5 Forms

Trang 42

Giới thiệu

• Các thành phần mới trong HTML5 bổ sung thêm chức năng mà các nhà thiết kế/phát triển web thường kết hợp quan các

phương tiện khác như javascript và Flash.

• HTML5 = HTML4 + một số thẻ thêm +

validation

42

Trang 43

Một số thẻ trong Form

• <input type = “text” … /> (password)

• <input type = “radio” … />

• <input type = “checkbox” … />

• <input type = “file” … />

• <input type = “submit” … /> (reset, button)

Trang 44

13 New Input Types

Trang 45

– required– step

Trang 46

Thẻ input có thuộc tính type mới

Trang 47

Thành phần label

• Thành phần không bắt buộc, tăng khả

năng truy cập cho form.

• <label for="txtPhone">Phone</label>

• <input type="text" name="txtPhone"

id="txtPhone">

47

Trang 48

<input type> search

Dùng để search hỗ trợ bởi Chrome, Opera, và Safari.

Search Google:

<input type="search" name="googlesearch" />`

Trang 49

<input type> email

Hỗ trợ bởi Chrome, Opera, firefox và safari.

E-mail: <input type="email" name="usermail" />

Trang 50

<input type> url

Dùng để nhập liệu địa chỉ web(URL address).

submit.

Hỗ trợ bởi Chrome, Opera, firefox.

Add your homepage:

<input type="url" name="homepage" />

Trang 51

<input type> range

Hỗ trợ Opera và WebKit (Chrome) Gồm có các thuộc tính min, max, và step

Trang 53

<input type> color

The color input type (type="color") provides the

user with a color picker Supported only in Opera,

Chrome

Select your favorite color:

<input type="color" name="favcolor" />

Trang 55

Date Pickers

<form>

<input type="date">

<input type="datetime">

<input type="datetime-local">

<input type=“time">

<input type="week">

<input type="month">

<input type="submit">

</form>

Trang 56

JavaScript Date Picker

function show_calendar(str_target, str_datetime) {

var arr_months = ["January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "December"];

var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];

var n_weekstart = 1; // day week starts from (normally 0 or 1)

var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime)); var dt_prev_month = new Date(dt_datetime);

Trang 57

Color Pickers

<form>

<input type="color">

</form>

Trang 58

<input type> keygen

The purpose of the <keygen> element is to provide a secure way to authenticate users

The <keygen> 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

<form action="demo_keygen.asp" method="get">

Username: <input type="text" name="usr_name" />

Encryption: <keygen name="security" />

<input type="submit" />

</form>

Trang 59

<input type> output

The <output> element represents the result of a calculation (like one performed by a script)

<form

oninput="x.value=parseInt(a.value)+parseInt(b.value)">0

<input type="range" name="a" value="50" />100

+<input type="number" name="b" value="50" />

=<output name="x" for="a b"></output>

</form>

Trang 60

Data Lists

<form>

<input type=“text” list=“states”>

<datalist id=“states” >

<option value=“AK” label=“Alaska”>

<option value=“AL” label=“Alabama”>

<option value=“AR” label=“Arkansas”>

</datalist>

</form>

Trang 61

61

<datalist id="frameworks">

<option value="MooTools">

<option value="Moobile">

<option value="Dojo Toolkit">

<option value="jQuery">

<option value="YUI">

</datalist>

<input name="frameworks" list="frameworks" />

Trang 62

• Các thuộc tính mới autofocus , required ,

textbox.

HTML5 Form Attribute Enhancements

Trang 63

Placeholder Text

<form>

<input name="q" placeholder=“Search Text">

<input type="submit" value="Search">

</form>

Trang 64

Autofocus Fields

<form>

<input name="q" autofocus>

<input type="submit" value="Search">

</form>

Trang 65

<form>

<input type="text" required>

<input type="hidden" required>

<input type="image" required>

Trang 66

Validation Example

Trang 68

Q & A

Trang 69

THE END

Ngày đăng: 17/03/2015, 14:43

TỪ KHÓA LIÊN QUAN