SlideShare a Scribd company logo
1 of 54
Download to read offline
HTML5 – 201
Nolan Erck
About Me
● Independent Consultant – Southofshasta.com
● Co-Manager - SacInteractive User Group
● Stuff I've used: HTML, ColdFusion, .NET, PHP,
C++, Java, JavaScript, jQuery, SQL, etc.
● Stuff I've done: CycleGear, Cast Images, Grim
Fandango, SimPark, SimSafari, Star Wars
Episode 1, .
● Music junkie.
HTML5
● The spec has been finalized...finally!
● Browser support is getting pretty good
– (except for those IE people)
● BUT...
– Just because the spec is final doesn't mean
browsers support everything yet.
● Example: SVG fonts barely work anywhere
● CanIUse.com
HTML5
● Several technologies, being marketed
together.
● <HTML5>
● CSS3
● JavaScript
● SVG, etc
Basic HTML5 Things
● First stuff we used
– Easier DOCTYPE tags
– Rules about <tags /> aren't as strict
– <section>, <aside>, etc.
– Yes, <canvas> too.
– New HTML form elements
● (browser support still in progress).
– New CSS
● Media queries, shadows, transparency/opacity,
importing fonts, etc.
Stuff we'll cover today
● Autofocus and Placeholder
● SVG
● Audio and Video
● Geolocation
● Drag and Drop
● Data Sets
● Custom elements
● Other resources, questions, etc.
Autofocus
<!DOCTYPE html>
<body>
<form action="submit.cfm">
First name: <input autofocus type="text" placeholder=”Your First Name”
name="fname" /><br />
Last name: <input type="text" name="lname"
placeholder=”Your Last Name” /><br />
Age: <input type="text" />
<input type="submit" />
</form>
</body>
</html>
No more JavaScript needed to set focus on a form field!
(Demo 1)
SVG – Scalable Vector Graphics
● Draw vector graphics in HTML “on the fly”
– No JPGs or PNGs required.
<svg>
<circle cx="50" cy="50" r="30" />
<rect x="0" y="0" width="100" height="100" />
</svg>
(Demo 2)
SVG – Scalable Vector Graphics
● Can do favicons in SVG for higher resolution
images.
● Currently only works in Firefox.
– For cross browser stuff, use normal .ICO files.
Audio
<audio>
<source src="chopin.mp3" type="audio/mpeg" />
</audio>
● Supports “graceful degradation”.
● WAV files don't work in Firefox yet.
● MP3 isn't an "open" standard, support may vary.
● See also: Web Audio API for high-level processing
– (No IE support yet, but Edge works.)
(Demo 3)
Video
● Works same as <audio>
<video width="400" controls>
<source src="UnavailableFile.ogg" type="video/ogg">
<source src="Buckethead.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
● Same as MP3/audio, MP4 isn't open standard
– Support may vary
(Demo 4)
Geolocation
● Determining where a user is located.
<script>
navigator.geolocation.getCurrentPosition(success,
error);
function success() { /* found the user's location */ }
function error() { /* can't find location */ }
</script>
(Demo 5)
Data Sets
● Can specify extra “meta data” to describe an element in your
HTML.
● Old way:
<div id=”CustID_123_City_London_Age_69”>David
Bowie</div>
● What if we don't know the city?
<div id=”CustID_123_City__Age_69”>David Bowie</div>
● Data is inconsistent, have to write various hacks to deal with all
the variations of missing data.
Data Sets
● New way...with data sets!
<div id=”myUser” data-custid=”123” data-city=”London”
data-age=”69”>
David Bowie
</div>
● Can name a property anything you want, just prefix it with
“data-”. Treated as valid HTML markup.
● To access it via JavaScript:
var el = document.querySelector('#myUser');
el.dataset.age = 64;
el.dataset.city = “New York City”;
(Demo 6)
Drag and Drop
● Make an element draggable:
– <img id=”myHeadshot” draggable="true">
● Then, specify what should happen when the element
is dragged:
– ondragstart="drag(event)"
Drag and Drop
function drag(ev) {
ev.dataTransfer.setData("userID", ev.target.id);
}
The dataTransfer.setData() method sets the data
name and the value of the dragged data.
Type is "userID" and the value is the id of the
draggable element ("myHeadshot").
Drag and Drop
● Where we're dragging this item to:
– <div id="premireUsers" ondrop="drop(event)"
ondragover="allowDrop(event)"></div>
● ondragover event specifies where the dragged
data can be dropped.
● By default, data/elements cannot be dropped
INTO other elements. To allow a drop, we
must prevent the default handling of the
element.
– event.preventDefault()
(Demo 7)
Editable Content
● Inline editable content on a web page.
● No need to swap <div> and <input> or have
“read only” and “edit” templates.
<section id="editable" contenteditable="true">
● Listen for whatever JavaScript events make
sense for your app, and save the data to local
storage, ajax, whatever.
(Demo 8)
Custom Elements
● Create your own HTML tags.
var MyTreehouseElement = document.registerElement('my-
treehouse');
● Means I can do this in HTML:
<my-treehouse> … </my-treehouse>
● x-treehouse is treated as a first class citizen (same as
<aside>, <div>, whatever).
● Name of your custom element must contain a dash (-) so the
browsers can determine between standard and custom HTML
elements.
● (See also: <template> and Polymer).
(Demo 9)
Extending Existing Elements
var ThumbImage = document.registerElement('thumb-img', {
prototype: ThumbImageProto,
extends: 'img' });
● To use your custom element:
<img is="thumb-img">
● There are a number of callbacks that you can listen for
when creating and managing your custom elements.
Extending Existing Elements
● Use callbacks to fire JavaScript via this event:
● createdCallback – Called when a custom element is
created.
● attachedCallback – Called when a custom element is
inserted into the DOM.
● detachedCallback – Called when a custom element is
removed from the DOM.
● attributeChangedCallback(attrName, oldValue,
newValue) – Called when an attribute on a custom
element changes.
(No demo...browser support is pretty bad still.)
But wait there's more!
● Offline webapps via the “cache.manifest” file.
● Cryptography.
● IndexedDB – client side databases.
● Ambient light, websockets, animations, touch
events, HTML templates, spellcheck, clipboard
API and on and on and ON! Phew!
● Lots of smart people here at the conference –
ask what they're doing!
Other resources
● W3schools.com
– Examples of pretty much anything
● CanIUse.com
● Html5demos.com
● Html5shiv on GitHub
– For VERY basic old-IE support
● Modernizr.com
– For testing HTML5/CSS3 support
● DiveIntoHTML5.info
● Polymer project
– Custom elements w/ better browser support.
Questions?
● Contact info:
– Southofshasta.com
– nolan@southofshasta.com
– Twitter: @southofshasta
Thanks!
HTML5 – 201
Nolan Erck
About Me
● Independent Consultant – Southofshasta.com
● Co-Manager - SacInteractive User Group
● Stuff I've used: HTML, ColdFusion, .NET, PHP,
C++, Java, JavaScript, jQuery, SQL, etc.
● Stuff I've done: CycleGear, Cast Images, Grim
Fandango, SimPark, SimSafari, Star Wars
Episode 1, .
● Music junkie.
HTML5
● The spec has been finalized...finally!
● Browser support is getting pretty good
– (except for those IE people)
● BUT...
– Just because the spec is final doesn't mean
browsers support everything yet.
● Example: SVG fonts barely work anywhere
● CanIUse.com
HTML5
● Several technologies, being marketed
together.
● <HTML5>
● CSS3
● JavaScript
● SVG, etc
Basic HTML5 Things
● First stuff we used
– Easier DOCTYPE tags
– Rules about <tags /> aren't as strict
– <section>, <aside>, etc.
– Yes, <canvas> too.
– New HTML form elements
● (browser support still in progress).
– New CSS
● Media queries, shadows, transparency/opacity,
importing fonts, etc.
Stuff we'll cover today
● Autofocus and Placeholder
● SVG
● Audio and Video
● Geolocation
● Drag and Drop
● Data Sets
● Custom elements
● Other resources, questions, etc.
Autofocus
<!DOCTYPE html>
<body>
<form action="submit.cfm">
First name: <input autofocus type="text" placeholder=”Your First Name”
name="fname" /><br />
Last name: <input type="text" name="lname"
placeholder=”Your Last Name” /><br />
Age: <input type="text" />
<input type="submit" />
</form>
</body>
</html>
No more JavaScript needed to set focus on a form field!
(Demo 1)
SVG – Scalable Vector Graphics
● Draw vector graphics in HTML “on the fly”
– No JPGs or PNGs required.
<svg>
<circle cx="50" cy="50" r="30" />
<rect x="0" y="0" width="100" height="100" />
</svg>
(Demo 2)
SVG – Scalable Vector Graphics
● Can do favicons in SVG for higher resolution
images.
● Currently only works in Firefox.
– For cross browser stuff, use normal .ICO files.
Audio
<audio>
<source src="chopin.mp3" type="audio/mpeg" />
</audio>
● Supports “graceful degradation”.
● WAV files don't work in Firefox yet.
● MP3 isn't an "open" standard, support may vary.
● See also: Web Audio API for high-level processing
– (No IE support yet, but Edge works.)
(Demo 3)
Video
● Works same as <audio>
<video width="400" controls>
<source src="UnavailableFile.ogg" type="video/ogg">
<source src="Buckethead.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
● Same as MP3/audio, MP4 isn't open standard
– Support may vary
(Demo 4)
Geolocation
● Determining where a user is located.
<script>
navigator.geolocation.getCurrentPosition(success,
error);
function success() { /* found the user's location */ }
function error() { /* can't find location */ }
</script>
(Demo 5)
Data Sets
● Can specify extra “meta data” to describe an element in your
HTML.
● Old way:
<div id=”CustID_123_City_London_Age_69”>David
Bowie</div>
● What if we don't know the city?
<div id=”CustID_123_City__Age_69”>David Bowie</div>
● Data is inconsistent, have to write various hacks to deal with all
the variations of missing data.
Data Sets
● New way...with data sets!
<div id=”myUser” data-custid=”123” data-city=”London”
data-age=”69”>
David Bowie
</div>
● Can name a property anything you want, just prefix it with
“data-”. Treated as valid HTML markup.
● To access it via JavaScript:
var el = document.querySelector('#myUser');
el.dataset.age = 64;
el.dataset.city = “New York City”;
(Demo 6)
Drag and Drop
● Make an element draggable:
– <img id=”myHeadshot” draggable="true">
● Then, specify what should happen when the element
is dragged:
– ondragstart="drag(event)"
Drag and Drop
function drag(ev) {
ev.dataTransfer.setData("userID", ev.target.id);
}
The dataTransfer.setData() method sets the data
name and the value of the dragged data.
Type is "userID" and the value is the id of the
draggable element ("myHeadshot").
Drag and Drop
● Where we're dragging this item to:
– <div id="premireUsers" ondrop="drop(event)"
ondragover="allowDrop(event)"></div>
● ondragover event specifies where the dragged
data can be dropped.
● By default, data/elements cannot be dropped
INTO other elements. To allow a drop, we
must prevent the default handling of the
element.
– event.preventDefault()
(Demo 7)
Editable Content
● Inline editable content on a web page.
● No need to swap <div> and <input> or have
“read only” and “edit” templates.
<section id="editable" contenteditable="true">
● Listen for whatever JavaScript events make
sense for your app, and save the data to local
storage, ajax, whatever.
(Demo 8)
Custom Elements
● Create your own HTML tags.
var MyTreehouseElement = document.registerElement('my-
treehouse');
● Means I can do this in HTML:
<my-treehouse> … </my-treehouse>
● x-treehouse is treated as a first class citizen (same as
<aside>, <div>, whatever).
● Name of your custom element must contain a dash (-) so the
browsers can determine between standard and custom HTML
elements.
● (See also: <template> and Polymer).
(Demo 9)
Extending Existing Elements
var ThumbImage = document.registerElement('thumb-img', {
prototype: ThumbImageProto,
extends: 'img' });
● To use your custom element:
<img is="thumb-img">
● There are a number of callbacks that you can listen for
when creating and managing your custom elements.
Extending Existing Elements
● Use callbacks to fire JavaScript via this event:
● createdCallback – Called when a custom element is
created.
● attachedCallback – Called when a custom element is
inserted into the DOM.
● detachedCallback – Called when a custom element is
removed from the DOM.
● attributeChangedCallback(attrName, oldValue,
newValue) – Called when an attribute on a custom
element changes.
(No demo...browser support is pretty bad still.)
But wait there's more!
● Offline webapps via the “cache.manifest” file.
● Cryptography.
● IndexedDB – client side databases.
● Ambient light, websockets, animations, touch
events, HTML templates, spellcheck, clipboard
API and on and on and ON! Phew!
● Lots of smart people here at the conference –
ask what they're doing!
Other resources
● W3schools.com
– Examples of pretty much anything
● CanIUse.com
● Html5demos.com
● Html5shiv on GitHub
– For VERY basic old-IE support
● Modernizr.com
– For testing HTML5/CSS3 support
● DiveIntoHTML5.info
● Polymer project
– Custom elements w/ better browser support.
Questions?
● Contact info:
– Southofshasta.com
– nolan@southofshasta.com
– Twitter: @southofshasta
Thanks!

More Related Content

Viewers also liked

ColdFusion builder 3 making the awesome
ColdFusion builder 3  making the awesomeColdFusion builder 3  making the awesome
ColdFusion builder 3 making the awesomeColdFusionConference
 
Accessible Video Anywhere with ColdFusion an AWS
Accessible Video Anywhere with ColdFusion an AWSAccessible Video Anywhere with ColdFusion an AWS
Accessible Video Anywhere with ColdFusion an AWSColdFusionConference
 
Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipColdFusionConference
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with BackboneColdFusionConference
 
Dev objecttives-2015 auth-auth-fine-grained-slides
Dev objecttives-2015 auth-auth-fine-grained-slidesDev objecttives-2015 auth-auth-fine-grained-slides
Dev objecttives-2015 auth-auth-fine-grained-slidesColdFusionConference
 
Language enhancements in cold fusion 11
Language enhancements in cold fusion 11Language enhancements in cold fusion 11
Language enhancements in cold fusion 11ColdFusionConference
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISColdFusionConference
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqColdFusionConference
 
Hey my web app is slow where is the problem
Hey my web app is slow where is the problemHey my web app is slow where is the problem
Hey my web app is slow where is the problemColdFusionConference
 

Viewers also liked (20)

Marketing for developers
Marketing for developersMarketing for developers
Marketing for developers
 
2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd2015 in tothebox-introtddbdd
2015 in tothebox-introtddbdd
 
ColdFusion builder 3 making the awesome
ColdFusion builder 3  making the awesomeColdFusion builder 3  making the awesome
ColdFusion builder 3 making the awesome
 
Building Multi-Tenant Saas Apps
Building  Multi-Tenant Saas AppsBuilding  Multi-Tenant Saas Apps
Building Multi-Tenant Saas Apps
 
Building Software in a weekend
Building Software in a weekendBuilding Software in a weekend
Building Software in a weekend
 
Workflows and Digital Signatures
Workflows and Digital SignaturesWorkflows and Digital Signatures
Workflows and Digital Signatures
 
Realtime with-websockets-2015
Realtime with-websockets-2015Realtime with-websockets-2015
Realtime with-websockets-2015
 
Accessible Video Anywhere with ColdFusion an AWS
Accessible Video Anywhere with ColdFusion an AWSAccessible Video Anywhere with ColdFusion an AWS
Accessible Video Anywhere with ColdFusion an AWS
 
Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanship
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with Backbone
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
Relationships are hard
Relationships are hardRelationships are hard
Relationships are hard
 
Cold fusion is racecar fast
Cold fusion is racecar fastCold fusion is racecar fast
Cold fusion is racecar fast
 
Dev objecttives-2015 auth-auth-fine-grained-slides
Dev objecttives-2015 auth-auth-fine-grained-slidesDev objecttives-2015 auth-auth-fine-grained-slides
Dev objecttives-2015 auth-auth-fine-grained-slides
 
Realtime with websockets
Realtime with websocketsRealtime with websockets
Realtime with websockets
 
Automate all the things
Automate all the thingsAutomate all the things
Automate all the things
 
Language enhancements in cold fusion 11
Language enhancements in cold fusion 11Language enhancements in cold fusion 11
Language enhancements in cold fusion 11
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APIS
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
Hey my web app is slow where is the problem
Hey my web app is slow where is the problemHey my web app is slow where is the problem
Hey my web app is slow where is the problem
 

More from ColdFusionConference

Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsColdFusionConference
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectColdFusionConference
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerColdFusionConference
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016ColdFusionConference
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016ColdFusionConference
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusionConference
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMSColdFusionConference
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webColdFusionConference
 

More from ColdFusionConference (20)

Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Cf ppt vsr
Cf ppt vsrCf ppt vsr
Cf ppt vsr
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIs
 
Don't just pdf, Smart PDF
Don't just pdf, Smart PDFDon't just pdf, Smart PDF
Don't just pdf, Smart PDF
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API Manager
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusion
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and web
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Securing applications
Securing applicationsSecuring applications
Securing applications
 
Testing automaton
Testing automatonTesting automaton
Testing automaton
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy experts
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Html5 201

  • 2. About Me ● Independent Consultant – Southofshasta.com ● Co-Manager - SacInteractive User Group ● Stuff I've used: HTML, ColdFusion, .NET, PHP, C++, Java, JavaScript, jQuery, SQL, etc. ● Stuff I've done: CycleGear, Cast Images, Grim Fandango, SimPark, SimSafari, Star Wars Episode 1, . ● Music junkie.
  • 3.
  • 4.
  • 5.
  • 6. HTML5 ● The spec has been finalized...finally! ● Browser support is getting pretty good – (except for those IE people) ● BUT... – Just because the spec is final doesn't mean browsers support everything yet. ● Example: SVG fonts barely work anywhere ● CanIUse.com
  • 7. HTML5 ● Several technologies, being marketed together. ● <HTML5> ● CSS3 ● JavaScript ● SVG, etc
  • 8. Basic HTML5 Things ● First stuff we used – Easier DOCTYPE tags – Rules about <tags /> aren't as strict – <section>, <aside>, etc. – Yes, <canvas> too. – New HTML form elements ● (browser support still in progress). – New CSS ● Media queries, shadows, transparency/opacity, importing fonts, etc.
  • 9. Stuff we'll cover today ● Autofocus and Placeholder ● SVG ● Audio and Video ● Geolocation ● Drag and Drop ● Data Sets ● Custom elements ● Other resources, questions, etc.
  • 10. Autofocus <!DOCTYPE html> <body> <form action="submit.cfm"> First name: <input autofocus type="text" placeholder=”Your First Name” name="fname" /><br /> Last name: <input type="text" name="lname" placeholder=”Your Last Name” /><br /> Age: <input type="text" /> <input type="submit" /> </form> </body> </html> No more JavaScript needed to set focus on a form field! (Demo 1)
  • 11. SVG – Scalable Vector Graphics ● Draw vector graphics in HTML “on the fly” – No JPGs or PNGs required. <svg> <circle cx="50" cy="50" r="30" /> <rect x="0" y="0" width="100" height="100" /> </svg> (Demo 2)
  • 12. SVG – Scalable Vector Graphics ● Can do favicons in SVG for higher resolution images. ● Currently only works in Firefox. – For cross browser stuff, use normal .ICO files.
  • 13. Audio <audio> <source src="chopin.mp3" type="audio/mpeg" /> </audio> ● Supports “graceful degradation”. ● WAV files don't work in Firefox yet. ● MP3 isn't an "open" standard, support may vary. ● See also: Web Audio API for high-level processing – (No IE support yet, but Edge works.) (Demo 3)
  • 14. Video ● Works same as <audio> <video width="400" controls> <source src="UnavailableFile.ogg" type="video/ogg"> <source src="Buckethead.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> ● Same as MP3/audio, MP4 isn't open standard – Support may vary (Demo 4)
  • 15. Geolocation ● Determining where a user is located. <script> navigator.geolocation.getCurrentPosition(success, error); function success() { /* found the user's location */ } function error() { /* can't find location */ } </script> (Demo 5)
  • 16. Data Sets ● Can specify extra “meta data” to describe an element in your HTML. ● Old way: <div id=”CustID_123_City_London_Age_69”>David Bowie</div> ● What if we don't know the city? <div id=”CustID_123_City__Age_69”>David Bowie</div> ● Data is inconsistent, have to write various hacks to deal with all the variations of missing data.
  • 17. Data Sets ● New way...with data sets! <div id=”myUser” data-custid=”123” data-city=”London” data-age=”69”> David Bowie </div> ● Can name a property anything you want, just prefix it with “data-”. Treated as valid HTML markup. ● To access it via JavaScript: var el = document.querySelector('#myUser'); el.dataset.age = 64; el.dataset.city = “New York City”; (Demo 6)
  • 18. Drag and Drop ● Make an element draggable: – <img id=”myHeadshot” draggable="true"> ● Then, specify what should happen when the element is dragged: – ondragstart="drag(event)"
  • 19. Drag and Drop function drag(ev) { ev.dataTransfer.setData("userID", ev.target.id); } The dataTransfer.setData() method sets the data name and the value of the dragged data. Type is "userID" and the value is the id of the draggable element ("myHeadshot").
  • 20. Drag and Drop ● Where we're dragging this item to: – <div id="premireUsers" ondrop="drop(event)" ondragover="allowDrop(event)"></div> ● ondragover event specifies where the dragged data can be dropped. ● By default, data/elements cannot be dropped INTO other elements. To allow a drop, we must prevent the default handling of the element. – event.preventDefault() (Demo 7)
  • 21. Editable Content ● Inline editable content on a web page. ● No need to swap <div> and <input> or have “read only” and “edit” templates. <section id="editable" contenteditable="true"> ● Listen for whatever JavaScript events make sense for your app, and save the data to local storage, ajax, whatever. (Demo 8)
  • 22. Custom Elements ● Create your own HTML tags. var MyTreehouseElement = document.registerElement('my- treehouse'); ● Means I can do this in HTML: <my-treehouse> … </my-treehouse> ● x-treehouse is treated as a first class citizen (same as <aside>, <div>, whatever). ● Name of your custom element must contain a dash (-) so the browsers can determine between standard and custom HTML elements. ● (See also: <template> and Polymer). (Demo 9)
  • 23. Extending Existing Elements var ThumbImage = document.registerElement('thumb-img', { prototype: ThumbImageProto, extends: 'img' }); ● To use your custom element: <img is="thumb-img"> ● There are a number of callbacks that you can listen for when creating and managing your custom elements.
  • 24. Extending Existing Elements ● Use callbacks to fire JavaScript via this event: ● createdCallback – Called when a custom element is created. ● attachedCallback – Called when a custom element is inserted into the DOM. ● detachedCallback – Called when a custom element is removed from the DOM. ● attributeChangedCallback(attrName, oldValue, newValue) – Called when an attribute on a custom element changes. (No demo...browser support is pretty bad still.)
  • 25. But wait there's more! ● Offline webapps via the “cache.manifest” file. ● Cryptography. ● IndexedDB – client side databases. ● Ambient light, websockets, animations, touch events, HTML templates, spellcheck, clipboard API and on and on and ON! Phew! ● Lots of smart people here at the conference – ask what they're doing!
  • 26. Other resources ● W3schools.com – Examples of pretty much anything ● CanIUse.com ● Html5demos.com ● Html5shiv on GitHub – For VERY basic old-IE support ● Modernizr.com – For testing HTML5/CSS3 support ● DiveIntoHTML5.info ● Polymer project – Custom elements w/ better browser support.
  • 27. Questions? ● Contact info: – Southofshasta.com – nolan@southofshasta.com – Twitter: @southofshasta Thanks!
  • 29. About Me ● Independent Consultant – Southofshasta.com ● Co-Manager - SacInteractive User Group ● Stuff I've used: HTML, ColdFusion, .NET, PHP, C++, Java, JavaScript, jQuery, SQL, etc. ● Stuff I've done: CycleGear, Cast Images, Grim Fandango, SimPark, SimSafari, Star Wars Episode 1, . ● Music junkie.
  • 30.
  • 31.
  • 32.
  • 33. HTML5 ● The spec has been finalized...finally! ● Browser support is getting pretty good – (except for those IE people) ● BUT... – Just because the spec is final doesn't mean browsers support everything yet. ● Example: SVG fonts barely work anywhere ● CanIUse.com
  • 34. HTML5 ● Several technologies, being marketed together. ● <HTML5> ● CSS3 ● JavaScript ● SVG, etc
  • 35. Basic HTML5 Things ● First stuff we used – Easier DOCTYPE tags – Rules about <tags /> aren't as strict – <section>, <aside>, etc. – Yes, <canvas> too. – New HTML form elements ● (browser support still in progress). – New CSS ● Media queries, shadows, transparency/opacity, importing fonts, etc.
  • 36. Stuff we'll cover today ● Autofocus and Placeholder ● SVG ● Audio and Video ● Geolocation ● Drag and Drop ● Data Sets ● Custom elements ● Other resources, questions, etc.
  • 37. Autofocus <!DOCTYPE html> <body> <form action="submit.cfm"> First name: <input autofocus type="text" placeholder=”Your First Name” name="fname" /><br /> Last name: <input type="text" name="lname" placeholder=”Your Last Name” /><br /> Age: <input type="text" /> <input type="submit" /> </form> </body> </html> No more JavaScript needed to set focus on a form field! (Demo 1)
  • 38. SVG – Scalable Vector Graphics ● Draw vector graphics in HTML “on the fly” – No JPGs or PNGs required. <svg> <circle cx="50" cy="50" r="30" /> <rect x="0" y="0" width="100" height="100" /> </svg> (Demo 2)
  • 39. SVG – Scalable Vector Graphics ● Can do favicons in SVG for higher resolution images. ● Currently only works in Firefox. – For cross browser stuff, use normal .ICO files.
  • 40. Audio <audio> <source src="chopin.mp3" type="audio/mpeg" /> </audio> ● Supports “graceful degradation”. ● WAV files don't work in Firefox yet. ● MP3 isn't an "open" standard, support may vary. ● See also: Web Audio API for high-level processing – (No IE support yet, but Edge works.) (Demo 3)
  • 41. Video ● Works same as <audio> <video width="400" controls> <source src="UnavailableFile.ogg" type="video/ogg"> <source src="Buckethead.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> ● Same as MP3/audio, MP4 isn't open standard – Support may vary (Demo 4)
  • 42. Geolocation ● Determining where a user is located. <script> navigator.geolocation.getCurrentPosition(success, error); function success() { /* found the user's location */ } function error() { /* can't find location */ } </script> (Demo 5)
  • 43. Data Sets ● Can specify extra “meta data” to describe an element in your HTML. ● Old way: <div id=”CustID_123_City_London_Age_69”>David Bowie</div> ● What if we don't know the city? <div id=”CustID_123_City__Age_69”>David Bowie</div> ● Data is inconsistent, have to write various hacks to deal with all the variations of missing data.
  • 44. Data Sets ● New way...with data sets! <div id=”myUser” data-custid=”123” data-city=”London” data-age=”69”> David Bowie </div> ● Can name a property anything you want, just prefix it with “data-”. Treated as valid HTML markup. ● To access it via JavaScript: var el = document.querySelector('#myUser'); el.dataset.age = 64; el.dataset.city = “New York City”; (Demo 6)
  • 45. Drag and Drop ● Make an element draggable: – <img id=”myHeadshot” draggable="true"> ● Then, specify what should happen when the element is dragged: – ondragstart="drag(event)"
  • 46. Drag and Drop function drag(ev) { ev.dataTransfer.setData("userID", ev.target.id); } The dataTransfer.setData() method sets the data name and the value of the dragged data. Type is "userID" and the value is the id of the draggable element ("myHeadshot").
  • 47. Drag and Drop ● Where we're dragging this item to: – <div id="premireUsers" ondrop="drop(event)" ondragover="allowDrop(event)"></div> ● ondragover event specifies where the dragged data can be dropped. ● By default, data/elements cannot be dropped INTO other elements. To allow a drop, we must prevent the default handling of the element. – event.preventDefault() (Demo 7)
  • 48. Editable Content ● Inline editable content on a web page. ● No need to swap <div> and <input> or have “read only” and “edit” templates. <section id="editable" contenteditable="true"> ● Listen for whatever JavaScript events make sense for your app, and save the data to local storage, ajax, whatever. (Demo 8)
  • 49. Custom Elements ● Create your own HTML tags. var MyTreehouseElement = document.registerElement('my- treehouse'); ● Means I can do this in HTML: <my-treehouse> … </my-treehouse> ● x-treehouse is treated as a first class citizen (same as <aside>, <div>, whatever). ● Name of your custom element must contain a dash (-) so the browsers can determine between standard and custom HTML elements. ● (See also: <template> and Polymer). (Demo 9)
  • 50. Extending Existing Elements var ThumbImage = document.registerElement('thumb-img', { prototype: ThumbImageProto, extends: 'img' }); ● To use your custom element: <img is="thumb-img"> ● There are a number of callbacks that you can listen for when creating and managing your custom elements.
  • 51. Extending Existing Elements ● Use callbacks to fire JavaScript via this event: ● createdCallback – Called when a custom element is created. ● attachedCallback – Called when a custom element is inserted into the DOM. ● detachedCallback – Called when a custom element is removed from the DOM. ● attributeChangedCallback(attrName, oldValue, newValue) – Called when an attribute on a custom element changes. (No demo...browser support is pretty bad still.)
  • 52. But wait there's more! ● Offline webapps via the “cache.manifest” file. ● Cryptography. ● IndexedDB – client side databases. ● Ambient light, websockets, animations, touch events, HTML templates, spellcheck, clipboard API and on and on and ON! Phew! ● Lots of smart people here at the conference – ask what they're doing!
  • 53. Other resources ● W3schools.com – Examples of pretty much anything ● CanIUse.com ● Html5demos.com ● Html5shiv on GitHub – For VERY basic old-IE support ● Modernizr.com – For testing HTML5/CSS3 support ● DiveIntoHTML5.info ● Polymer project – Custom elements w/ better browser support.
  • 54. Questions? ● Contact info: – Southofshasta.com – nolan@southofshasta.com – Twitter: @southofshasta Thanks!