1. HTML5 and CSS3- One UI for All
Mobile Phone Form Factors
Puneet Kumar, Mobile Team, IFS
2. Intuit Proprietary & Confidential
2
Agenda
•HTML5 Crash course(20min)
•CSS3 Crash course(10min)
•Responsive Design(10 min)
– Problem definition
– Current Solution
– Proposed Solution
– How can Responsive Design help!
3. Intuit Proprietary & Confidential
Logistics
• This presentation is Part 1 of HTML/CSS Workshop at
TechForum, Intuit, Feb 21, 2012
• This presentation at Brainstorm:
https://intuit.intuitbrainstorm.com/Idea.aspx?
id=11398
• Q&A, at the end
• Post questions to
http://tiles.intuit.com/tiles/site/tile/HTML5#
3
5. Intuit Proprietary & Confidential
HTML5 Features
• New Doctype
• Semantic Tags
• Forms, new input types
• Video, Audio
• Canvas
• Web Storage
• Offline
• Web Workers
• GeoLocation
• Drag and drop
5
Many cool features to explore
6. Intuit Proprietary & Confidential
HTML5, New Doctype
• <!DOCTYPE html>
6
<!DOCTYPE html>
Benefit:
Simple.
• <!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans
itional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
14. Intuit Proprietary & Confidential
HTML5, Web Storage
• Web Storage- key value
– localStorage
– sessionStorage
– .setItem(‘data’, 12);
– .getItem(‘data’);
– .removeItem(‘data’)
– .clear()
– sessionStorage.length
– sessionStorage.key(i)
– Trap: Stored as Strings!
14
Better than cookies
Benefit:
Cookies on
steroids
15. Intuit Proprietary & Confidential
HTML5, Web SQL database
• Web SQL Storage- SQL database
• var db;
if(window.openDatabase){
db = openDatabase(‘myDB’, ‘1.0’, ‘test db’, 2 *1024 *1024);
db.transaction(function (tx) {
tx.executeSql(‘CREATE TABLE IF NOT EXISTS test(id, date, testdata)’,
[], function(){
)};//executeSql
)};//db.transaction
}
15
SQL syntax
Benefit:
Database in
Browser!
16. Intuit Proprietary & Confidential
HTML5, Offline
• Offline
• Application works even after network connectivity is
lost.
• Manifest file needs to know what to cache.
• <html manifest=“/time.manifest”>
• Apache mimes.types:
– text/cache-manifest manifest
16
No network, no problem
17. Intuit Proprietary & Confidential
HTML5, Web Workers
• Web workers
• var worker=new Worker(“myworker.js”);
worker.postMessage(“hello”);
worker.onMessage = function(event){
alert(‘The worker sent ’ + event.data);
};
//In myworker.js:
onmessage = function(event){
if(event.data == “hello”){
postMessage(“hello main”)
}else{
postMessage(“Busy right now!”);
}
}
17
multi threading
Benefit:
Responsive
pages
19. Intuit Proprietary & Confidential
CSS3
• CSS3 offers a huge variety of new ways to create an
impact with your designs.
• CSS 3 too has made its mark with its many features not
only augment the aesthetic appeal but also improve
functionality.
• Style your HTML markup using drop shadows, rounded
corners, multiple backgrounds, animation,
transparency.
• http://css3test.com/
• http://www.css3.info/preview/
19
23. Intuit Proprietary & Confidential23
Problem Definition
• Mobile phones have different widths
• Use Case
– Mobile Browsers with different form factor request mobile
page
– On Mobile Web server, User Agent is found
– DRS finds width of phone based on User Agent
– One of many style sheets is chosen(different widths,
Blackberry)
– Mobile page is styled
– Mobile Page presented to end user.
• Optimal?
– Multiple style sheets, more processing, multiple images,
Should we create multiple css files for different
mobile sizes
24. Intuit Proprietary & Confidential
Current Solution, Device Recognition Software
24
User Agent String
Https Request
Device Width etc
176
css
240
css
320
css
480
css
320
css
Black
berry
DRS Server
W
hich
css?
Mobile web page
DRS(http://tiles.intuit.com/tiles/site/tile/DRS)
26. Intuit Proprietary & Confidential26
Proposed Solution
• Use Case
– Mobile Browsers, with different widths, request mobile
page
– Flexible Mobile Page presented to end user.
• How?
– HTML5
– CSS3
– Responsive Design
– JQuery Mobile
27. Intuit Proprietary & Confidential
Proposed Solution, Responsive Design
27
Https Request
Responsive css
One
css!
Mobile web page
Responsive Design
28. Intuit Proprietary & Confidential28
Responsive Design, What is? pg1
• Flexible Grid
– Flexible Typesetting, font-size in em
– Flexible Grid, width in percentage
– Flexible margins and padding, in percentage
• Flexible Images
• Media Queries (CSS3)
font-size=1.25em; width=80%,
margin=5%,;padding 5%;
29. Intuit Proprietary & Confidential29
Responsive Design, What is? pg2
• Flexible Grid
• Flexible Images
– Fluid Images, max-width=100%;
– For IE, width=100%;
– For IE, use AlphaImageLoader
– Use overflow:hidden;
• Media Queries (CSS3)
max-width=100%; overflow:hidden;
30. Intuit Proprietary & Confidential30
Responsive Design, What is? pg3
• Flexible Grid
• Flexible Images
• Media Queries (CSS3 feature)
– media=“screen and (min-width:1024px)”
– CSS3 is not supported?
• Try css-mediaqueries.js
• Try respond.js
media=“screen and (min-width:1024px)”
A browser extension might allow a user to jump straight to the nav with a single keystroke. It can do this because it looks for nav rather than having to employ heuristics to find a div with an id or class that would suggest it’s being used as navigation. A restaurant site with a div called “menu” might be a list of foods rather than other pages. A crawler might dynamically assemble articles on a timeline.