Beruflich Dokumente
Kultur Dokumente
7/30/15
HTML5
7/30/15
New Doctype
Old
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
New
<!DOCTYPE html>
In fact, did you know that it truthfully isn't even really necessary
for HTML5? However, it's used for older browsers that require a
specified doctype. Browsers that do not understand this doctype
will simply render the contained markup in standards mode.
7/30/15
Meta Tag
7/30/15
Meta Tag
7/30/15
This means that the browser will (probably) render the width
of the page at the width of its own screen. So if that screen is
320px wide, the browser window will be 320px wide, rather
than way zoomed out and showing 960px (or whatever that
device does by default
7/30/15
7/30/15
New
<link rel="stylesheet" href="path/to/stylesheet.css" />
<script src="path/to/script.js"></script>
7/30/15
7/30/15
10
7/30/15
11
HTML5 Inputs
HTML5 introduces no less than a bakers dozen (yes, thats
13!) new input types for forms. Were going to take a brief
look at each of them and explain why you should be using
them right now. These new input types have dual benefits:
using them means less development time and an improved
user experience. The new input types well be looking at are:
7/30/15
12
Search Input
Search seems like an appropriate place to start our foray into
HTML5 input types. When we talk about search, were not just
talking about Google, Bing, or Yahoo. Were talking about the
search field on that e-commerce site you just made a
purchase from, on Wikipedia, and even on your personal blog.
Its probably the most common action performed on the Web
every day, yet its not marked up very semantically, is it? We
all tend to write something like this:
7/30/15
13
7/30/15
14
Email Input
If we apply a type of "email" to form inputs, we can instruct
the browser to only allow strings that conform to a valid email
address structure. That's right; built-in form validation will
soon be here! We can't 100% rely on this just yet, for obvious
reasons. In older browsers that do not understand this "email"
type, they'll simply fall back to a regular textbox.
7/30/15
15
7/30/15
16
Tel Input
Phone numbers differ around the world, making it difficult to
guarantee any type of specific notation except for allowing
only numbers and perhaps a + symbol to be entered. Its
possible that you can validate specific phone numbers (if you
can guarantee the format) using client-side validation.
type="tel" is marked up as follows:
7/30/15
17
7/30/15
18
Required Attribute
Forms allow for a new required attribute, which specifies,
naturally, whether a particular input is required. Dependent
upon your coding preference, you can declare this attribute in
one of two ways:
7/30/15
19
Required Attribute
Either method will do. With this code, and within browsers that
support this attribute, a form cannot be submitted if that
"someInput" input is blank. Here's a quick example; we'll also
add the placeholder attribute as well, as there's no reason not
to.
If the input is left blank, and the form is submitted, the textbox
will be highlighted.
7/30/15
20
Autofocus Attribute
Again, HTML5 removes the need for JavaScript solutions. If a
particular input should be "selected," or focused, by default,
we can now utilize the autofocus attribute.
7/30/15
21
Audio Support
No longer do we have to rely upon third party plugins in order
to render audio. HTML5 now offers the <audio> element. Well,
at least, ultimately, we won't have to worry about these
plugins. For the time being, only the most recent of browsers
offer support for HTML5 audio. At this time, it's still a good
practice to offer some form of backward compatibility.
7/30/15
22
Video Support
Much like the <audio> element, we also, of course, have
HTML5 video as well in the new browsers! Unfortunately,
again, because the HTML5 spec doesn't specify a specific
codec for video, it's left to the browsers to decide. While
Safari, and Internet Explorer 9 can be expected to support
video in the H.264 format (which Flash players can play),
Firefox and Opera are sticking with the open source Theora
and Vorbis formats. As such, when displaying HTML5 video,
you must offer both formats.
7/30/15
23
Video Support
7/30/15
24
Regular Expressions
How often have you found yourself writing some quickie regular
expression to verify a particular textbox. Thanks to the new
pattern attribute, we can insert a regular expression directly into
our markup.
25
For example, if you find that you need to wrap a block of code
within a wrapper element specifically for the purpose of
positioning the content, a <div> makes perfect sense.
7/30/15
26
7/30/15
27
New
<figure>
<img src="path/to/image"
alt="About image" />
<figcaption>
<p>This is an image of
something interesting. </p>
</figcaption>
</figure>
7/30/15
7/30/15
29
7/30/15
30
CSS3
7/30/15
31
Element Selector
7/30/15
32
7/30/15
33
Fonts
7/30/15
34
Overflow
7/30/15
35
7/30/15
36
2D and 3D Transforms
7/30/15
37
7/30/15
38
Page Media
7/30/15
39
7/30/15
40
Resources
7/30/15
41
jQuery
7/30/15
42
7/30/15
43
jQuery('div#intro h2')
jQuery('div.section > p')
jQuery('input:radio')
$('div#intro h2')
7/30/15
44
jQuery collections
7/30/15
45
Manipulating collections
7/30/15
46
Grabbing values
Some methods return results from the first matched element
var height = $('div#intro').height();
var src = $('img.photo').attr('src');
v=ar lastP = $('p:last').html()
7/30/15
47
7/30/15
48
Handling events
7/30/15
49
Going unobtrusive
$(document).ready(function() {
alert('The DOM is ready!');
});
$(function() { alert('This is a shortcut') });
7/30/15
50
Chaining
7/30/15
51
Crazy chaining
$('form#login')
// hide all the labels inside the form with the 'optional' class
.find('label.optional').hide().end()
// add a red border to any password fields in the form
.find('input:password').css('border', '1px solid red').end()
// add a submit handler to the form
.submit(function(){
return confirm('Are you sure you want to submit?');
});
7/30/15
52
Ajax
7/30/15
53
Plugins
7/30/15
54
Further reading
THE END
7/30/15
55
7/30/15
56