SlideShare a Scribd company logo
Gran Sasso Science Institute
Ivano Malavolta
HTML5 & CSS3 refresher
Roadmap
Anatomy of a web app
HTML5
CSS3
What is a Web App?
A software built with web technologies that is accessible via a mobile
browser


The browser may be either 
the standard device browser 
or an embedded browser 
(Hybrid app)
Anatomy of a Web App
Data 
Usually mobile apps do not talk directly with the database

à do not even think about JDBC, drivers, etc!
Ć ļƒ ā€ÆThey pass through an application server and communicate via:
•  standard HTTP requests for HTML content (eg PHP)
•  REST-full services (XML, JSON, etc.)
•  SOAP
Data
•  Data can be stored in any classical way:
– Relational
– Graph
– Key-value
– Document-based

Latest trend à backend-as-a-service
BaaS
1.  Developers build a visual model of
their DB

2.  The service generates APIs and
client-side libraries(compatible
with Android, Windows Phone,
etc.)
3.  The data produced/consumed in
the app can be pushed/pulled to
their DB
–  Communication is handled via
REST-based APIs
Example of Baas software: BaasBox


Main features:
•  User management 
–  ACL
–  Friendships
–  Authentication via Facebook and Google+
•  Document-based data manegement (via OrientDB)
•  Assets management (fotos, documents, or files)
•  Push notifications
The ā€œBoxā€ in BaasBox means that all the features
are in a standalone server, just like a box. 

No Application Server, no Database Server, just
a JVM and nothing more
Rest API
Web
dashboard
http://www.baasbox.com/
Roadmap
Anatomy of a web app
HTML5
CSS3
HTML 5
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
HTML 5

HTML5 will be the new standard for HTML


HTML5 is still a work in progress

W3C final recomendation: 2020



Top browsers support many (not all) of the new HTML5 elements
http://mobilehtml5.org
http://caniuse.com
What is HTML5?
HTML5
Markup
 JavaScript
CSS3
Multimedia
The minimal HTML5 page
<!DOCTYPE	
 Ā html>	
 Ā 
<html>	
 Ā 
	
 Ā <head>	
 Ā 
	
 Ā <title>Title</title>	
 Ā 
</head>	
 Ā 
	
 Ā <body>	
 Ā 
…	
 Ā 
</body>	
 Ā 
</html>	
 Ā 
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
New Structural Tags
Main Goal: separate presentation from content

•  Poor accessibility
•  Unnecessary complexity
•  Larger document size

Most of the presentational features from earlier versions of
HTML are no longer supported
New Structural Tags
<header> header region of a page or section

<footer> footer region of a page or section

<nav> navigation region of a page or section

<section> logical region of a page

<article> a complete piece of content

<aside> secondary or related content
New Structural Tags
http://bit.ly/JCnuQJ
Other Structural Tags
<command> a command button that a user can invoke
<details> additional details that the user can view or hide
<summary> a visible heading for a <details> element
<meter> an amount within a range
<progress> shows real-time progress towards a goal
<figure> self-contained content, like illustrations,
diagrams, photos, code listings, etc.
<figcaption> caption of a figure
<mark> marked/highlighted text
<time> a date/time
<wbr>Defines a possible line-break
Custom Data Attributes
Can be used to add metadata about any element within an
HTML5 page

They are ignored by the validator for HTML5 documents

They all start with the data- pattern

They can be read by any browser using Javascript via the
getAttribute() method
HTML5 and CSS3 refresher
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
Forms
Main Goal: reduce the Javascript for validation and format
management
Example:
Form Input Types
Form input types degrade gracefully
à Unknown input types are treated as text-type
http://bit.ly/I65jai
Form Input Types
<input type="search"> for search boxes
<input type="number">Ā for spinboxes
<input type="range">Ā for sliders
<input type="color">Ā for color pickers
<input type="tel">Ā for telephone numbers
<input type="url">Ā for web addresses
<input type="email">Ā for email addresses
<input type="date">Ā for calendar date pickers
<input type="month">Ā for months
<input type="week">Ā for weeks
<input type="time"> for timestamps
<input type="datetime"> for precise timestamps
<input type="datetime-local">Ā for local dates and times
Form Field Attributes
Autofocus
–  Support for placing the focus on a specific form element
<input type="textā€œ autofocus>
Placeholder
–  Support for placing placeholder text inside a form field
<input type="textā€œ placeholder=ā€œyour nameā€>
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Server-Sent Events
•  Canvas & SVG
Audio
<audio> : a standard way to embed an audio file on a web page

<audio controls>
<source src="song.ogg" type="audio/ogg" />
<source src="song.mp3" type="audio/mpeg" />
Not Supported
</audio>
Multiple sources à the browser will use the first recognized
format
Audio Attributes
Audio Javascript API
HTML5 provides a set of Javascript APIs for interacting with an
audio element

For example:

play() pause() load() currentTime ended
volume…

à http://www.w3.org/wiki/HTML/Elements/audio
Video
<video> : a standard way to embed a video file on a web page

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Not Supported
</video>
Multiple sources à the browser will use the first recognized
format
Video attributes
Video Javascript API
HTML5 provides a set of Javascript APIs for interacting with a
video element

For example:

play() pause() load() currentTime ended
volume…

à http://www.w3.org/wiki/HTML/Elements/video
A note on YouTube videos
<video> works only if you have a direct link to the
MP4 file of the YouTube video

If you have just a link to the YouTube page of your video,
simply embed it in your page

<iframe width="560" height="315" src="http://
www.youtube.com/embed/Wp20Sc8qPeo" frameborder="0"
allowfullscreen></iframe>
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
Offline Data
LocalStorage

stores data in key/value pairs

it is tied to a specific domain/app

persists across browser sessions

SessionStorage

stores data in key/value pairs

it is tied to a specific domain/app

data is erased when a browser session ends
Offline Data
WebSQL Database

relational DB

support for tables creation, insert, update, …

transactional

tied to a specific domain/app

persists across browser sessions

Its evolution is called IndexedDB, but it is actually not supported
by most mobile browsers
Offline data
Mobile browsers compatibility matrix
We will have a dedicated lecture to offline data
storage on mobile devices
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
Geolocalization
Gets Latitude and Longitude from the user’s browser

There is also a watchPosition method wich calls a JS function
every time the user moves


We will have a dedicated lecture to
geolocalization on mobile devices
Example
function getLocation() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log(ā€˜no geolocalization’);
}
}
function showPosition(position) {
console.log(position.coords.latitude);
console.log(position.coords.longitude);
}
getCurrentPosition()
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
WebSockets
Bidirectional, full-duplex communication between devices and
server

Specifically suited for

chat, videogames, drawings sharing, real-time info

Requires a Web Socket Server to handle the protocol
WebSockets - Overview
1.  Client notifies websocket server (EventMachine) of an event,
giving ids of recipients
2.  The server notifies all the active clients (subscribed to that type
of event)
3.  Clients process event 

when given recipient Id 

matches the client’s one
http://bit.ly/Ixcupi
Alternative - Polling via AJAX
+ Near real-time updates (not purely real-time)
+ easy to implement
+ no new technologies needed

-  they are requested from the client and cause increased
network traffic
-  AJAX requests generally have a small payload and relatively
high amount of http headers (wasted bandwith)
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Canvas & SVG
Canvas & SVG
Canvas & SVG allow you to create graphics inside the browser
We will have a dedicated
lecture to canvas & SVG
on mobile devices
http://bit.ly/Ie4HKu
Canvas & SVG
Canvas

draws 2D graphics, on the fly

you use Javascript to draw on the canvas
Ā  
rendered pixel by pixel

SVG

describes 2D graphics in XML

every element is available within the SVG DOM

JavaScript event handlers for an element
Roadmap
•  Intro
•  New Structural Tags and Attributes
•  Forms
•  Audio & Video
•  Offline Data
•  Geolocalization
•  Web Sockets
•  Server-Sent Events
•  Canvas & SVG
Roadmap
Anatomy of a web app
HTML5
CSS3
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Intro
Let’s imagine Flipboard without CSS3
CSS3 Main Drivers
Simplicity
–  less images
–  less markup
–  less Javascript
–  less Flash
Better performance
–  fewer HTTP requests
Better Search Engine Placement
–  text as real text, not images or Flash
–  speed
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Basics
Generic Syntax:

selector {
property: value;
property2: value2, value3;
...
}
Inheritance
If an HTML element B is nested into another element A 
Ć ļƒ ā€ÆB inherits the style of A unless B has an explicit style
definition


body {
background-color: red;
}
div {
background-color: green;
}
Combining Selectors
Selectors can be combined


h1, h2, h3 {
background-color: red;
}
Lists
div {
list-style-image: url(image.png);
list-style-position: inside;
list-style-style: circle;
}

Position
inside | outside
Style
disc | circle
square | decimal
lower-roman |
upper-roman |
lower-alpha |
upper-alpha |
none
Backgrounds
You can style a background of any element

div {
background:url(img.png), url(img2.png);
background-size:80px 60px;
background-repeat:no-repeat;
background-origin:content-box;
}

repeat
no-repeat | repeat
repeat-x | repeat-y
origin
top left | top center | top right | center left
| border-box | content-box etc.
Background & Colors
div {
background-color: blue;
background-color: rgba(0, 0, 255, 0.2);
background-color: hsla(240, 100%, 50%, 0.2);
}

RGBA = RGB + opacity
HSLA = HSL + opacity
HSL
hue
saturation
lightness
Gradients
They can be used in every place you can use an image

div {
background: -webkit-gradient(linear, right top,
left bottom, from(red), green));
}
linear à the type of gradient (also radial, or repeating-linear)
right-top à start of the gradient 
left-bottom à end of the gradient
from à starting color
to à final color
Text
p {
color: grey;
letter-spacing: 5px;
text-align: center;
text-decoration: underline;
text-indent: 10px;
text-transform: capitalize;
word-spacing: 10px;
}
text-align
left | right
center | justify
Text-decoration
none 
underline
overline
line through
text-transform
none | capitalize | 
lowercase | uppercase
Text Effects
p {
text-shadow: 2px 10px 5px #FF0000;
text-overflow: ellipsis;
word-wrap:break-word;
}
2px à horizontal shadow 
10px à vertical shadow 
5px à blur distance 
#FF0000 à color
Other Text Properties
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Selectors
Classical ways to select elements in CSS2:

•  by type 
a { color: red; }

•  by id 
#redLink { color: red; }
•  by class 








 























.redLink { color: red; }
Other Selectors from CSS1 & CSS2
•  div p à all <p> elements inside a <div>
•  div>p à all <p> elements where the parent is a <div> 
•  div+p à all <p> elements that are placed immediately after
<div>
•  [target] à all elements with a target attribute
•  [target=_blank] à all elements with target= "_blankā€œ
•  p:first-child à every <p> element that is the first child of its
parent
Some selectors introduced in CSS3
•  a[src^="https"] à every <a> element whose src attribute
value begins with "httpsā€
•  a[src$=".pdf"] à every <a> element whose src attribute value
ends with ".pdfā€
•  a[src*=ā€œmobile"] à every <a> element whose src attribute
value contains the substring ā€œmobileā€œ
•  p:nth-child(2) à every <p> element that is the second child of
its parent
•  p:nth-last-child(2) à every <p> element that is the second
child of its parent, counting from the last child
•  :not(p) à every element that is not a <p> element
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
The Box Model
http://www.adamkaplan.me/grid/
http://www.adamkaplan.me/grid/
Tip





Tells the browser not to include borders and padding in the
width of your content

Ć ļƒ ā€Æ you have more control on the layout of your app
http://www.adamkaplan.me/grid/
Tip
Borders & dimensions
div {
width: 100px;
height: 40px;
padding: 10px;
border: 5px solid gray;
margin: 10px;
border-radius: 10px;
box-shadow: 10px 10px 5px red;
}
Images as borders
div {
border-image:url(border.png) 30 30 round;
}
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
The Display Property
It specifies if and how an element is displayed

div {
display: none;
}
The element will be hidden, and the page will be displayed as if the
element is not there
The Display Property
Other usual values:

block
•  a block element is an element that takes up the full width
available, and has a line break before and after it

inline
•  an inline element only takes up as much width as necessary
•  it can contain only other inline elements

inline-block
•  the element is placed as an inline element (on the same line
as adjacent content), but it behaves as a block element
–  you can set width and height, top and bottom margins and paddings
The visibility Property
It specifies if an element should be visible or hidden

div.hidden {
visibility: hidden;
}
The element will be hidden, but still affect the layout
It can also be set to 
visible, collapse, inherit
Flex Box
It helps in styling elements to be arranged horizontally or
vertically
box:
•  a new value for theĀ displayĀ property
•  a new property box-orient

#div {
display: box;
box-orient: horizontal;
}
Flex Box main elements
display: box

opts an element and its immediate children into the flexible
box model

box-orient

Values:Ā horizontalĀ |Ā verticalĀ |Ā inherit

How should the box's children be aligned? 

box-direction

Values:Ā normalĀ |Ā reverseĀ |Ā inherit

sets the order in which the elements will be displayed
Flex Box main elements
box-pack

Values:Ā startĀ |Ā endĀ |Ā centerĀ |Ā justify

Sets the alignment of the box along theĀ box-orientĀ axis

box-orient: horizontal;
box-pack: end;
Flex Box main elements
box-align

Values:Ā startĀ |Ā endĀ |Ā centerĀ |Ā baselineĀ |Ā stretch

Sets how the box's children are aligned in the box
box-orient: horizontal;
box-align: center;
Flex Box Children

by default child elements are not flexible

à their dimension is set according to their width
box-flex can be set to any integer
It sets how a child element occupy the 
box’s space

#box1 {
width: 100px;
}
#box2 {
box-flex: 1;
}
#box3 {
box-flex: 2;
}
Positioning
•  Static
•  Relative
•  Absolute
•  Fixed
•  Inherit
Static Positioning
Elements will stack one on top of the next

http://bit.ly/I8cEaF
Relative Positioning
Elements behave exactly the same 
way as statically positioned elements

we can adjust a relatively positioned 
element with offset properties:Ā 
top,Ā right,Ā bottom, andĀ left
http://bit.ly/I8cEaF
Relative Positioning
It is possible to create a coordinate system for child elements
http://bit.ly/I8cEaF
Absolute Positioning
an absolutely positioned element is removed from the normal flow

it won’tĀ affect or be 
affectedĀ by any other 
element in the flow
http://bit.ly/I8cEaF
Fixed Positioning
shares all the rules of an absolutely positioned element

a fixed element does not scroll with the document
http://bit.ly/I8cEaF
Float

A floated element will move as far to the left or right as it can

Elements are floated only horizontally

The floatĀ CSS property can accept one of 4 values:Ā 
left,Ā right,Ā none, andĀ inherit
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Fonts
Before CSS3, web designers had to use fonts that were already
installed on the user's device

With CSS3, web designers can use whatever font they like

@font-face {
font-family: NAME;
src: url(Dimbo.ttf);
font-weight: normal;
font-style: normal;
}

font-style
normal
italic
oblique
font-weight
normal
bold
100
200
…
Fonts Usage
To use the font for an HTML element, refer to the name of the
font (NAME) through the font-family property
div {
font-family: NAME;
}
Some Fonts Sources...
www.dafont.com
www.urbanfonts.com
www.losttype.com
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Visual Effects
Three main mechanisms:

1.  Transforms (both 2D and 3D)
2.  Transitions
3.  Animations
Transforms
A transform is an effect that lets an element 
change shape, size, position, … 

You can transform your elements using 2D or 3D transformations
http://bit.ly/IroJ7S
Transforms
http://bit.ly/IrpUnX
Transforms
http://bit.ly/IrpUnX
Transitions
They are used to add an effect when changing from one style to
another

The effect can be gradual


The effect will start when the specified CSS property changes
value
Transition syntax
A transition contains 4 properties:

•  property
–  the name of the CSS property the transition effect is for (can be all)
•  duration
–  how many seconds (or milliseconds) the transition effect takes to
complete
•  timing-function
–  linear, ease, ease-in, ease-out, ease-in-out
•  delay
–  when the transition effect will start
Example
.imageThumbnail {
width; 200px;
transition: all ease-in 3s;
}
.zoomed {
position: absolute;
left: 0px;
top: 0px;
width: 480px;
}
$(ā€˜.imageThumbnail’).addClass(ā€˜zoomed’);
Animations
An animation is an effect that lets an element gradually change
from one style to another

You can change style in loop, repeating, etc. 

To bind an animation to an element, you have to specify at least:
1.  Name of the animation
2.  Duration of the animation
div {
animation: test 5s ease-in;
}
Animation Definition
An animation is defined in a keyframe

It splits the animation into parts, and assign a specific style to
each part

The various steps within an animation are given as percentuals

0% à beginning of the animation (from)
100% à end of the animation (to)
Example
@keyframes test{
0% {background: red; left:0px; top:0px;}
25% {background: yellow; left:200px; top:0px;}
50% {background: blue; left:200px; top:200px;}
75% {background: green; left:0px; top:200px;}
100% {background: red; left:0px; top:0px;}
}
results in
http://goo.gl/kFZrLs
Animation Properties
http://bit.ly/IrpUnX
Transitions VS Animations
•  Trigger
–  Transitions must be bound to a CSS property change
–  Animations start autonomously
•  States
–  Transitions have start and end states
–  Animations can have multiple states
•  Repeats
–  Transitions can be perfomed once for each activation
–  Animations can be looped
Roadmap
•  Intro
•  Basics
•  Selectors
•  Box Model
•  Positioning & Floats
•  Fonts
•  Visual Effects
•  Media Queries
Media Types
Media Queries are based on Media Types

A media type is a specification of the actual media that is being
used to access the page

Examples of media types include
•  screen: computer screens
•  print: printed document
•  braille: for Braille-based devices
•  tv: for television devices
Media Types
There are two main ways to specify a media type:

•  <link> in the HTML page


<link rel=ā€œstylesheetā€
href=ā€œstyle.cssā€ media=ā€œscreenā€ />
•  @media within the CSS file


@media screen {
div { color: red; }
}
Media Queries
They allow you to to change style based on specific conditions

For example, they can be about
•  device’s display size
•  orientation of the device
•  Resolution of the display
•  ...
Example
http://bit.ly/I5mR1u
Media Queries
A media query is a boolean expression

The CSS associated with the media query expression is applied
only if it evaluates to true

A media query consists of
1.  a media type
2.  a set of media features



@media screen and orientation: portrait
The Full Media Feature List
http://slidesha.re/I5oFHZ
The AND operator
You can combine multiple expressions by using the and operator


@media screen and (max-device-width: 480px){
/* your style */
}
The COMMA operator
The comma keyword acts as an or operator


@media screen and (color),
handheld and (color) {
/* your style */
}
The NOT operator
You can explicitly ignore a specific type of device by using the not
operator


@media not (width:480px) {
/* your style */
}
Examples
Retina Displays
@media only screen and -webkit-min-device-pixel-ratio: 2
iPad in landscape orientation
@media only screen and
(device-width: 768px) and (orientation: landscape)
iPhone and Android devices
@media only screen and
(min-device-width: 320px) and (max-device-width: 480px)
References







http://www.w3schools.com
https://developer.mozilla.org/en-US/docs/Web/CSS
+ 39 380 70 21 600
Contact
Ivano Malavolta | 
Gran Sasso Science Institute
iivanoo
ivano.malavolta@univaq.it
www.ivanomalavolta.com

More Related Content

PDF
Local storage in Web apps
Ivano Malavolta
Ā 
PDF
HTML5: the new frontier of the web
Ivano Malavolta
Ā 
PDF
Modern development paradigms
Ivano Malavolta
Ā 
PDF
[2015/2016] Backbone JS
Ivano Malavolta
Ā 
PPTX
HTL(Sightly) - All you need to know
Prabhdeep Singh
Ā 
PPTX
Angular jS Introduction by Google
ASG
Ā 
PPTX
SPSNH 2014 - The SharePoint & jQueryGuide
Mark Rackley
Ā 
PPTX
AEM - Client Libraries
Prabhdeep Singh
Ā 
Local storage in Web apps
Ivano Malavolta
Ā 
HTML5: the new frontier of the web
Ivano Malavolta
Ā 
Modern development paradigms
Ivano Malavolta
Ā 
[2015/2016] Backbone JS
Ivano Malavolta
Ā 
HTL(Sightly) - All you need to know
Prabhdeep Singh
Ā 
Angular jS Introduction by Google
ASG
Ā 
SPSNH 2014 - The SharePoint & jQueryGuide
Mark Rackley
Ā 
AEM - Client Libraries
Prabhdeep Singh
Ā 

What's hot (20)

PDF
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
SPTechCon
Ā 
KEY
Templates
soon
Ā 
PDF
Workshop HTML5+PhoneGap by Ivano Malavolta
Commit University
Ā 
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
Ā 
PPTX
SPTechCon 2014 How to develop and debug client side code in SharePoint
Mark Rackley
Ā 
PPTX
Sightly - Part 2
Prabhdeep Singh
Ā 
PPTX
MVC & SQL_In_1_Hour
Dilip Patel
Ā 
PPTX
Bringing HTML5 alive in SharePoint
Chad Schroeder
Ā 
PPTX
More object oriented development with Page Type Builder
joelabrahamsson
Ā 
PPTX
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
Ā 
PPTX
SPSTC - SharePoint & jQuery Essentials
Mark Rackley
Ā 
PDF
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
Evolve The Adobe Digital Marketing Community
Ā 
PPTX
Introduction to using jQuery with SharePoint
Rene Modery
Ā 
PDF
JavaScript and jQuery for SharePoint Developers
Rob Windsor
Ā 
PPTX
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Fabio Franzini
Ā 
PPTX
Session 35 - Design Patterns
PawanMM
Ā 
KEY
Wicket 2010
Martijn Dashorst
Ā 
PPT
Asp.net
Naveen Sihag
Ā 
PPTX
Session 36 - JSP - Part 1
PawanMM
Ā 
PDF
AEM Sightly Template Language
Gabriel Walt
Ā 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
SPTechCon
Ā 
Templates
soon
Ā 
Workshop HTML5+PhoneGap by Ivano Malavolta
Commit University
Ā 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
Ā 
SPTechCon 2014 How to develop and debug client side code in SharePoint
Mark Rackley
Ā 
Sightly - Part 2
Prabhdeep Singh
Ā 
MVC & SQL_In_1_Hour
Dilip Patel
Ā 
Bringing HTML5 alive in SharePoint
Chad Schroeder
Ā 
More object oriented development with Page Type Builder
joelabrahamsson
Ā 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
Ā 
SPSTC - SharePoint & jQuery Essentials
Mark Rackley
Ā 
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
Evolve The Adobe Digital Marketing Community
Ā 
Introduction to using jQuery with SharePoint
Rene Modery
Ā 
JavaScript and jQuery for SharePoint Developers
Rob Windsor
Ā 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Fabio Franzini
Ā 
Session 35 - Design Patterns
PawanMM
Ā 
Wicket 2010
Martijn Dashorst
Ā 
Asp.net
Naveen Sihag
Ā 
Session 36 - JSP - Part 1
PawanMM
Ā 
AEM Sightly Template Language
Gabriel Walt
Ā 
Ad

Viewers also liked (6)

PDF
Handlebars and Require.js
Ivano Malavolta
Ā 
PDF
The mobile ecosystem
Ivano Malavolta
Ā 
PDF
Introduction to javascript templating using handlebars.js
Mindfire Solutions
Ā 
DOCX
Report html5
Himanshu Phulara
Ā 
PDF
RequireJS & Handlebars
Ivano Malavolta
Ā 
PDF
UI design for mobile apps
Ivano Malavolta
Ā 
Handlebars and Require.js
Ivano Malavolta
Ā 
The mobile ecosystem
Ivano Malavolta
Ā 
Introduction to javascript templating using handlebars.js
Mindfire Solutions
Ā 
Report html5
Himanshu Phulara
Ā 
RequireJS & Handlebars
Ivano Malavolta
Ā 
UI design for mobile apps
Ivano Malavolta
Ā 
Ad

Similar to HTML5 and CSS3 refresher (20)

PDF
HTML5 Refresher
Ivano Malavolta
Ā 
PDF
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
Ā 
PDF
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
Ā 
PPTX
HTML5: An Overview
Nagendra Um
Ā 
PDF
A brief introduction on HTML5 and responsive layouts
Tim Wray
Ā 
PPTX
HTML5 Programming
hotrannam
Ā 
PPTX
HTML5 introduction for beginners
Vineeth N Krishnan
Ā 
PPTX
Html 5
Nguyen Quang
Ā 
PDF
Word camp nextweb
Panagiotis Grigoropoulos
Ā 
PDF
WordCamp Thessaloniki2011 The NextWeb
George Kanellopoulos
Ā 
ODP
Html5
mikusuraj
Ā 
PPTX
Html5
Zahin Omar Alwa
Ā 
PDF
Streaming Visualization
Guido Schmutz
Ā 
PPT
php
bhuvana553
Ā 
PDF
HTML5 features & JavaScript APIs
Fisnik Doko
Ā 
PPTX
Html5
Chris Young
Ā 
PPTX
Presentation about html5 css3
Gopi A
Ā 
PPTX
Creating Great Applications in SharePoint 2010 with Silverlight 4
Boston Area SharePoint Users Group
Ā 
PPTX
Html5 phillycc
Jennifer Kenderdine
Ā 
HTML5 Refresher
Ivano Malavolta
Ā 
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
Ā 
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
Ā 
HTML5: An Overview
Nagendra Um
Ā 
A brief introduction on HTML5 and responsive layouts
Tim Wray
Ā 
HTML5 Programming
hotrannam
Ā 
HTML5 introduction for beginners
Vineeth N Krishnan
Ā 
Html 5
Nguyen Quang
Ā 
Word camp nextweb
Panagiotis Grigoropoulos
Ā 
WordCamp Thessaloniki2011 The NextWeb
George Kanellopoulos
Ā 
Html5
mikusuraj
Ā 
Streaming Visualization
Guido Schmutz
Ā 
php
bhuvana553
Ā 
HTML5 features & JavaScript APIs
Fisnik Doko
Ā 
Html5
Chris Young
Ā 
Presentation about html5 css3
Gopi A
Ā 
Creating Great Applications in SharePoint 2010 with Silverlight 4
Boston Area SharePoint Users Group
Ā 
Html5 phillycc
Jennifer Kenderdine
Ā 

More from Ivano Malavolta (20)

PDF
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
Ā 
PDF
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Ivano Malavolta
Ā 
PDF
The H2020 experience
Ivano Malavolta
Ā 
PDF
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Ivano Malavolta
Ā 
PDF
Software sustainability and Green IT
Ivano Malavolta
Ā 
PDF
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Ivano Malavolta
Ā 
PDF
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Ivano Malavolta
Ā 
PDF
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Ivano Malavolta
Ā 
PDF
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Ivano Malavolta
Ā 
PDF
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Ivano Malavolta
Ā 
PDF
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ivano Malavolta
Ā 
PDF
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Ivano Malavolta
Ā 
PDF
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Ivano Malavolta
Ā 
PDF
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Ivano Malavolta
Ā 
PDF
Modeling and abstraction, software development process [Software Design] [Com...
Ivano Malavolta
Ā 
PDF
[2017/2018] Agile development
Ivano Malavolta
Ā 
PDF
Reconstructing microservice-based architectures
Ivano Malavolta
Ā 
PDF
[2017/2018] AADL - Architecture Analysis and Design Language
Ivano Malavolta
Ā 
PDF
[2017/2018] Architectural languages
Ivano Malavolta
Ā 
PDF
[2017/2018] Introduction to Software Architecture
Ivano Malavolta
Ā 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
Ā 
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Ivano Malavolta
Ā 
The H2020 experience
Ivano Malavolta
Ā 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Ivano Malavolta
Ā 
Software sustainability and Green IT
Ivano Malavolta
Ā 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Ivano Malavolta
Ā 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Ivano Malavolta
Ā 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Ivano Malavolta
Ā 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Ivano Malavolta
Ā 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Ivano Malavolta
Ā 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ivano Malavolta
Ā 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Ivano Malavolta
Ā 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Ivano Malavolta
Ā 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Ivano Malavolta
Ā 
Modeling and abstraction, software development process [Software Design] [Com...
Ivano Malavolta
Ā 
[2017/2018] Agile development
Ivano Malavolta
Ā 
Reconstructing microservice-based architectures
Ivano Malavolta
Ā 
[2017/2018] AADL - Architecture Analysis and Design Language
Ivano Malavolta
Ā 
[2017/2018] Architectural languages
Ivano Malavolta
Ā 
[2017/2018] Introduction to Software Architecture
Ivano Malavolta
Ā 

Recently uploaded (20)

PDF
Software Development Methodologies in 2025
KodekX
Ā 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
Ā 
PDF
Doc9.....................................
SofiaCollazos
Ā 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
Ā 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
Ā 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
Ā 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
Ā 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
PDF
Software Development Company | KodekX
KodekX
Ā 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
Ā 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
Ā 
Doc9.....................................
SofiaCollazos
Ā 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
Ā 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
Ā 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
Ā 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
Ā 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
Software Development Company | KodekX
KodekX
Ā 
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
Ā 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 

HTML5 and CSS3 refresher

  • 1. Gran Sasso Science Institute Ivano Malavolta HTML5 & CSS3 refresher
  • 2. Roadmap Anatomy of a web app HTML5 CSS3
  • 3. What is a Web App? A software built with web technologies that is accessible via a mobile browser The browser may be either the standard device browser or an embedded browser (Hybrid app)
  • 4. Anatomy of a Web App
  • 5. Data Usually mobile apps do not talk directly with the database à do not even think about JDBC, drivers, etc! Ć ļƒ ā€ÆThey pass through an application server and communicate via: •  standard HTTP requests for HTML content (eg PHP) •  REST-full services (XML, JSON, etc.) •  SOAP
  • 6. Data •  Data can be stored in any classical way: – Relational – Graph – Key-value – Document-based Latest trend à backend-as-a-service
  • 7. BaaS 1.  Developers build a visual model of their DB 2.  The service generates APIs and client-side libraries(compatible with Android, Windows Phone, etc.) 3.  The data produced/consumed in the app can be pushed/pulled to their DB –  Communication is handled via REST-based APIs
  • 8. Example of Baas software: BaasBox Main features: •  User management –  ACL –  Friendships –  Authentication via Facebook and Google+ •  Document-based data manegement (via OrientDB) •  Assets management (fotos, documents, or files) •  Push notifications The ā€œBoxā€ in BaasBox means that all the features are in a standalone server, just like a box. No Application Server, no Database Server, just a JVM and nothing more Rest API Web dashboard http://www.baasbox.com/
  • 9. Roadmap Anatomy of a web app HTML5 CSS3
  • 10. HTML 5 •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 11. HTML 5 HTML5 will be the new standard for HTML HTML5 is still a work in progress W3C final recomendation: 2020 Top browsers support many (not all) of the new HTML5 elements http://mobilehtml5.org http://caniuse.com
  • 12. What is HTML5? HTML5 Markup JavaScript CSS3 Multimedia
  • 13. The minimal HTML5 page <!DOCTYPE Ā html> Ā  <html> Ā  Ā <head> Ā  Ā <title>Title</title> Ā  </head> Ā  Ā <body> Ā  … Ā  </body> Ā  </html> Ā 
  • 14. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 15. New Structural Tags Main Goal: separate presentation from content •  Poor accessibility •  Unnecessary complexity •  Larger document size Most of the presentational features from earlier versions of HTML are no longer supported
  • 16. New Structural Tags <header> header region of a page or section <footer> footer region of a page or section <nav> navigation region of a page or section <section> logical region of a page <article> a complete piece of content <aside> secondary or related content
  • 18. Other Structural Tags <command> a command button that a user can invoke <details> additional details that the user can view or hide <summary> a visible heading for a <details> element <meter> an amount within a range <progress> shows real-time progress towards a goal <figure> self-contained content, like illustrations, diagrams, photos, code listings, etc. <figcaption> caption of a figure <mark> marked/highlighted text <time> a date/time <wbr>Defines a possible line-break
  • 19. Custom Data Attributes Can be used to add metadata about any element within an HTML5 page They are ignored by the validator for HTML5 documents They all start with the data- pattern They can be read by any browser using Javascript via the getAttribute() method
  • 21. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 22. Forms Main Goal: reduce the Javascript for validation and format management Example:
  • 23. Form Input Types Form input types degrade gracefully à Unknown input types are treated as text-type http://bit.ly/I65jai
  • 24. Form Input Types <input type="search"> for search boxes <input type="number">Ā for spinboxes <input type="range">Ā for sliders <input type="color">Ā for color pickers <input type="tel">Ā for telephone numbers <input type="url">Ā for web addresses <input type="email">Ā for email addresses <input type="date">Ā for calendar date pickers <input type="month">Ā for months <input type="week">Ā for weeks <input type="time"> for timestamps <input type="datetime"> for precise timestamps <input type="datetime-local">Ā for local dates and times
  • 25. Form Field Attributes Autofocus –  Support for placing the focus on a specific form element <input type="textā€œ autofocus> Placeholder –  Support for placing placeholder text inside a form field <input type="textā€œ placeholder=ā€œyour nameā€>
  • 26. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Server-Sent Events •  Canvas & SVG
  • 27. Audio <audio> : a standard way to embed an audio file on a web page <audio controls> <source src="song.ogg" type="audio/ogg" /> <source src="song.mp3" type="audio/mpeg" /> Not Supported </audio> Multiple sources à the browser will use the first recognized format
  • 29. Audio Javascript API HTML5 provides a set of Javascript APIs for interacting with an audio element For example: play() pause() load() currentTime ended volume… à http://www.w3.org/wiki/HTML/Elements/audio
  • 30. Video <video> : a standard way to embed a video file on a web page <video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> Not Supported </video> Multiple sources à the browser will use the first recognized format
  • 32. Video Javascript API HTML5 provides a set of Javascript APIs for interacting with a video element For example: play() pause() load() currentTime ended volume… à http://www.w3.org/wiki/HTML/Elements/video
  • 33. A note on YouTube videos <video> works only if you have a direct link to the MP4 file of the YouTube video If you have just a link to the YouTube page of your video, simply embed it in your page <iframe width="560" height="315" src="http:// www.youtube.com/embed/Wp20Sc8qPeo" frameborder="0" allowfullscreen></iframe>
  • 34. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 35. Offline Data LocalStorage stores data in key/value pairs it is tied to a specific domain/app persists across browser sessions SessionStorage stores data in key/value pairs it is tied to a specific domain/app data is erased when a browser session ends
  • 36. Offline Data WebSQL Database relational DB support for tables creation, insert, update, … transactional tied to a specific domain/app persists across browser sessions Its evolution is called IndexedDB, but it is actually not supported by most mobile browsers
  • 37. Offline data Mobile browsers compatibility matrix We will have a dedicated lecture to offline data storage on mobile devices
  • 38. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 39. Geolocalization Gets Latitude and Longitude from the user’s browser There is also a watchPosition method wich calls a JS function every time the user moves We will have a dedicated lecture to geolocalization on mobile devices
  • 40. Example function getLocation() { if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { console.log(ā€˜no geolocalization’); } } function showPosition(position) { console.log(position.coords.latitude); console.log(position.coords.longitude); }
  • 42. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 43. WebSockets Bidirectional, full-duplex communication between devices and server Specifically suited for chat, videogames, drawings sharing, real-time info Requires a Web Socket Server to handle the protocol
  • 44. WebSockets - Overview 1.  Client notifies websocket server (EventMachine) of an event, giving ids of recipients 2.  The server notifies all the active clients (subscribed to that type of event) 3.  Clients process event when given recipient Id matches the client’s one http://bit.ly/Ixcupi
  • 45. Alternative - Polling via AJAX + Near real-time updates (not purely real-time) + easy to implement + no new technologies needed -  they are requested from the client and cause increased network traffic -  AJAX requests generally have a small payload and relatively high amount of http headers (wasted bandwith)
  • 46. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Canvas & SVG
  • 47. Canvas & SVG Canvas & SVG allow you to create graphics inside the browser We will have a dedicated lecture to canvas & SVG on mobile devices http://bit.ly/Ie4HKu
  • 48. Canvas & SVG Canvas draws 2D graphics, on the fly you use Javascript to draw on the canvas Ā  rendered pixel by pixel SVG describes 2D graphics in XML every element is available within the SVG DOM JavaScript event handlers for an element
  • 49. Roadmap •  Intro •  New Structural Tags and Attributes •  Forms •  Audio & Video •  Offline Data •  Geolocalization •  Web Sockets •  Server-Sent Events •  Canvas & SVG
  • 50. Roadmap Anatomy of a web app HTML5 CSS3
  • 51. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 53. CSS3 Main Drivers Simplicity –  less images –  less markup –  less Javascript –  less Flash Better performance –  fewer HTTP requests Better Search Engine Placement –  text as real text, not images or Flash –  speed
  • 54. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 55. Basics Generic Syntax: selector { property: value; property2: value2, value3; ... }
  • 56. Inheritance If an HTML element B is nested into another element A Ć ļƒ ā€ÆB inherits the style of A unless B has an explicit style definition body { background-color: red; } div { background-color: green; }
  • 57. Combining Selectors Selectors can be combined h1, h2, h3 { background-color: red; }
  • 58. Lists div { list-style-image: url(image.png); list-style-position: inside; list-style-style: circle; } Position inside | outside Style disc | circle square | decimal lower-roman | upper-roman | lower-alpha | upper-alpha | none
  • 59. Backgrounds You can style a background of any element div { background:url(img.png), url(img2.png); background-size:80px 60px; background-repeat:no-repeat; background-origin:content-box; } repeat no-repeat | repeat repeat-x | repeat-y origin top left | top center | top right | center left | border-box | content-box etc.
  • 60. Background & Colors div { background-color: blue; background-color: rgba(0, 0, 255, 0.2); background-color: hsla(240, 100%, 50%, 0.2); } RGBA = RGB + opacity HSLA = HSL + opacity HSL hue saturation lightness
  • 61. Gradients They can be used in every place you can use an image div { background: -webkit-gradient(linear, right top, left bottom, from(red), green)); } linear à the type of gradient (also radial, or repeating-linear) right-top à start of the gradient left-bottom à end of the gradient from à starting color to à final color
  • 62. Text p { color: grey; letter-spacing: 5px; text-align: center; text-decoration: underline; text-indent: 10px; text-transform: capitalize; word-spacing: 10px; } text-align left | right center | justify Text-decoration none underline overline line through text-transform none | capitalize | lowercase | uppercase
  • 63. Text Effects p { text-shadow: 2px 10px 5px #FF0000; text-overflow: ellipsis; word-wrap:break-word; } 2px à horizontal shadow 10px à vertical shadow 5px à blur distance #FF0000 à color
  • 65. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 66. Selectors Classical ways to select elements in CSS2: •  by type a { color: red; } •  by id #redLink { color: red; } •  by class .redLink { color: red; }
  • 67. Other Selectors from CSS1 & CSS2 •  div p à all <p> elements inside a <div> •  div>p à all <p> elements where the parent is a <div> •  div+p à all <p> elements that are placed immediately after <div> •  [target] à all elements with a target attribute •  [target=_blank] à all elements with target= "_blankā€œ •  p:first-child à every <p> element that is the first child of its parent
  • 68. Some selectors introduced in CSS3 •  a[src^="https"] à every <a> element whose src attribute value begins with "httpsā€ •  a[src$=".pdf"] à every <a> element whose src attribute value ends with ".pdfā€ •  a[src*=ā€œmobile"] à every <a> element whose src attribute value contains the substring ā€œmobileā€œ •  p:nth-child(2) à every <p> element that is the second child of its parent •  p:nth-last-child(2) à every <p> element that is the second child of its parent, counting from the last child •  :not(p) à every element that is not a <p> element
  • 69. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 71. http://www.adamkaplan.me/grid/ Tip Tells the browser not to include borders and padding in the width of your content Ć ļƒ ā€Æ you have more control on the layout of your app
  • 73. Borders & dimensions div { width: 100px; height: 40px; padding: 10px; border: 5px solid gray; margin: 10px; border-radius: 10px; box-shadow: 10px 10px 5px red; }
  • 74. Images as borders div { border-image:url(border.png) 30 30 round; }
  • 75. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 76. The Display Property It specifies if and how an element is displayed div { display: none; } The element will be hidden, and the page will be displayed as if the element is not there
  • 77. The Display Property Other usual values: block •  a block element is an element that takes up the full width available, and has a line break before and after it inline •  an inline element only takes up as much width as necessary •  it can contain only other inline elements inline-block •  the element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element –  you can set width and height, top and bottom margins and paddings
  • 78. The visibility Property It specifies if an element should be visible or hidden div.hidden { visibility: hidden; } The element will be hidden, but still affect the layout It can also be set to visible, collapse, inherit
  • 79. Flex Box It helps in styling elements to be arranged horizontally or vertically box: •  a new value for theĀ displayĀ property •  a new property box-orient #div { display: box; box-orient: horizontal; }
  • 80. Flex Box main elements display: box opts an element and its immediate children into the flexible box model box-orient Values:Ā horizontalĀ |Ā verticalĀ |Ā inherit How should the box's children be aligned? box-direction Values:Ā normalĀ |Ā reverseĀ |Ā inherit sets the order in which the elements will be displayed
  • 81. Flex Box main elements box-pack Values:Ā startĀ |Ā endĀ |Ā centerĀ |Ā justify Sets the alignment of the box along theĀ box-orientĀ axis box-orient: horizontal; box-pack: end;
  • 82. Flex Box main elements box-align Values:Ā startĀ |Ā endĀ |Ā centerĀ |Ā baselineĀ |Ā stretch Sets how the box's children are aligned in the box box-orient: horizontal; box-align: center;
  • 83. Flex Box Children by default child elements are not flexible à their dimension is set according to their width box-flex can be set to any integer It sets how a child element occupy the box’s space #box1 { width: 100px; } #box2 { box-flex: 1; } #box3 { box-flex: 2; }
  • 84. Positioning •  Static •  Relative •  Absolute •  Fixed •  Inherit
  • 85. Static Positioning Elements will stack one on top of the next http://bit.ly/I8cEaF
  • 86. Relative Positioning Elements behave exactly the same way as statically positioned elements we can adjust a relatively positioned element with offset properties:Ā  top,Ā right,Ā bottom, andĀ left http://bit.ly/I8cEaF
  • 87. Relative Positioning It is possible to create a coordinate system for child elements http://bit.ly/I8cEaF
  • 88. Absolute Positioning an absolutely positioned element is removed from the normal flow it won’tĀ affect or be affectedĀ by any other element in the flow http://bit.ly/I8cEaF
  • 89. Fixed Positioning shares all the rules of an absolutely positioned element a fixedĀ element does not scroll with the document http://bit.ly/I8cEaF
  • 90. Float A floated element will move as far to the left or right as it can Elements are floated only horizontally The floatĀ CSS property can accept one of 4 values:Ā  left,Ā right,Ā none, andĀ inherit
  • 91. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 92. Fonts Before CSS3, web designers had to use fonts that were already installed on the user's device With CSS3, web designers can use whatever font they like @font-face { font-family: NAME; src: url(Dimbo.ttf); font-weight: normal; font-style: normal; } font-style normal italic oblique font-weight normal bold 100 200 …
  • 93. Fonts Usage To use the font for an HTML element, refer to the name of the font (NAME) through the font-family property div { font-family: NAME; }
  • 95. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 96. Visual Effects Three main mechanisms: 1.  Transforms (both 2D and 3D) 2.  Transitions 3.  Animations
  • 97. Transforms A transform is an effect that lets an element change shape, size, position, … You can transform your elements using 2D or 3D transformations http://bit.ly/IroJ7S
  • 100. Transitions They are used to add an effect when changing from one style to another The effect can be gradual The effect will start when the specified CSS property changes value
  • 101. Transition syntax A transition contains 4 properties: •  property –  the name of the CSS property the transition effect is for (can be all) •  duration –  how many seconds (or milliseconds) the transition effect takes to complete •  timing-function –  linear, ease, ease-in, ease-out, ease-in-out •  delay –  when the transition effect will start
  • 102. Example .imageThumbnail { width; 200px; transition: all ease-in 3s; } .zoomed { position: absolute; left: 0px; top: 0px; width: 480px; } $(ā€˜.imageThumbnail’).addClass(ā€˜zoomed’);
  • 103. Animations An animation is an effect that lets an element gradually change from one style to another You can change style in loop, repeating, etc. To bind an animation to an element, you have to specify at least: 1.  Name of the animation 2.  Duration of the animation div { animation: test 5s ease-in; }
  • 104. Animation Definition An animation is defined in a keyframe It splits the animation into parts, and assign a specific style to each part The various steps within an animation are given as percentuals 0% à beginning of the animation (from) 100% à end of the animation (to)
  • 105. Example @keyframes test{ 0% {background: red; left:0px; top:0px;} 25% {background: yellow; left:200px; top:0px;} 50% {background: blue; left:200px; top:200px;} 75% {background: green; left:0px; top:200px;} 100% {background: red; left:0px; top:0px;} } results in http://goo.gl/kFZrLs
  • 107. Transitions VS Animations •  Trigger –  Transitions must be bound to a CSS property change –  Animations start autonomously •  States –  Transitions have start and end states –  Animations can have multiple states •  Repeats –  Transitions can be perfomed once for each activation –  Animations can be looped
  • 108. Roadmap •  Intro •  Basics •  Selectors •  Box Model •  Positioning & Floats •  Fonts •  Visual Effects •  Media Queries
  • 109. Media Types Media Queries are based on Media Types A media type is a specification of the actual media that is being used to access the page Examples of media types include •  screen: computer screens •  print: printed document •  braille: for Braille-based devices •  tv: for television devices
  • 110. Media Types There are two main ways to specify a media type: •  <link> in the HTML page <link rel=ā€œstylesheetā€ href=ā€œstyle.cssā€ media=ā€œscreenā€ /> •  @media within the CSS file @media screen { div { color: red; } }
  • 111. Media Queries They allow you to to change style based on specific conditions For example, they can be about •  device’s display size •  orientation of the device •  Resolution of the display •  ...
  • 113. Media Queries A media query is a boolean expression The CSS associated with the media query expression is applied only if it evaluates to true A media query consists of 1.  a media type 2.  a set of media features @media screen and orientation: portrait
  • 114. The Full Media Feature List http://slidesha.re/I5oFHZ
  • 115. The AND operator You can combine multiple expressions by using the and operator @media screen and (max-device-width: 480px){ /* your style */ }
  • 116. The COMMA operator The comma keyword acts as an or operator @media screen and (color), handheld and (color) { /* your style */ }
  • 117. The NOT operator You can explicitly ignore a specific type of device by using the not operator @media not (width:480px) { /* your style */ }
  • 118. Examples Retina Displays @media only screen and -webkit-min-device-pixel-ratio: 2 iPad in landscape orientation @media only screen and (device-width: 768px) and (orientation: landscape) iPhone and Android devices @media only screen and (min-device-width: 320px) and (max-device-width: 480px)
  • 120. + 39 380 70 21 600 Contact Ivano Malavolta | Gran Sasso Science Institute iivanoo [email protected] www.ivanomalavolta.com