On Github gdipgh / intro-to-html5-and-css3
There is a lot to cover for these technologies. This workshop is just an introduction.
Enhance our Women in Computing web site to use HTML5 & CSS3
The project folder is:
intro-to-html5-and-css3/activity/women-in-computing
If you're viewing the slides locally, it is here
Main international standards organization for the web
Do web sites need to be experienced exactly the same in every browser?
Gives some old elements semantic meaning and separates them from presentation (e.g. b, i, strong, em)
<!DOCTYPE html>
Minimum information required to ensure that a browser renders using standards mode
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Enhance our Women in Computing web site to use HTML5 & CSS3
<!DOCTYPE html>
<div id="header"></div>
<div class="nav"></div>
<div id="footer"></div>
<header></header>
<nav></nav>
<footer></footer>
<body> <div id="header"> <h1>Hi, I'm a header!</h1> <div id="nav"> <ul> <li><a href="foo">foo</a></li> <li><a href="bar">bar</a></li> </ul> </div> </div> <div id="main"> <div class="article">foo</div> <div class="article">bar</div> </div> <div id="footer">Hi, I'm a footer!</div> </body>
<body> <div id="header"> <h1>Hi, I'm a header!</h1> <div id="nav"> <ul> <li><a href="foo">foo</a></li> <li><a href="bar">bar</a></li> </ul> </div> </div> <div id="main"> <div class="article">foo</div> <div class="article">bar</div> </div> <div id="footer">Hi, I'm a footer!</div> </body>
also known as div-itis
<body> <header> <h1>Hi, I'm a header!</h1> <nav> <ul> <li><a href="http://www.foo.com">foo</a></li> <li><a href="http://www.bar.com">bar</a></li> </ul> </nav> </header> <section> <article>foo</article> <article>bar</article> </section> <footer>Hi, I'm a footer!</footer> </body>
It also helps treat the plague of div-itis!
HTML5 IE enabling script
<!--[if lt IE 9]> <script src="html5shiv.js"></script> <![endif]-->polyfill (n): a JavaScript shim that replicates the standard API for older browsers
Enhance our Women in Computing web site to use HTML5 & CSS3
If you get stuck, take a look at the example for inspiration
Audio and video are first class citizens in HTML5
Useful as a replacement for flash on mobile devices
Flash makes mobile devices sad :(
Rich, device-aware features and experiences
div[foo^="bar"] { color: red; } div[foo$="bar"] { background-color: red; } div[foo*="bar"] { border: solid 5px red; }
matches an element that has position an+b
element:nth-child(an + b) { style properties }
tbody tr:nth-child(an + b) { backround-color: red; }
n 2n+1 4n+1 4n+4 4n 5n-2 -n+3 0 1 1 4 - - 3 1 3 5 8 4 3 2 2 5 9 12 8 8 1 3 7 13 16 12 13 - 4 9 17 20 16 18 - 5 11 21 24 20 23 - reference
a user interface element which is enabled
input:enabled { background-color: red; } input:disabled { background-color: grey; }Enabled: Disabled:
a user interface element which is checked
input:checked + label { color: red; }
checkbox
radio radio radio
.example{ -moz-property: value; -ms-property: value; -webkit-property: value; -o-property: value; property: value; }
the non-prefixed property should always go last
Allows you to create rounded corners
#example1 { border-radius: 20px; }
20px on all corners
#example2 { border-radius: 10px 40px; }
10px on top left & bottom right
40px on top right & bottom left
#example3 { border-radius: 10px 20px 40px 80px; }
10px on top left
20px top right
40px bottom right
80px bottom left
#example4 { border-radius: 50%; }
Creates an ellipse
Creates a circle if height == width
control the opacity of a color
.example2.rgba { background-color: rgba(255, 0, 0, 0.8); }
color property using (red, green, blue, opacity)
opacity is a decimal value from 0 to 1
control the opacity of an element
.example2.opacity { opacity: 0.8; }
decimal value from 0 to 1
adds a drop shadow to an element
box-shadow: offset-x offset-y color
.example1 { box-shadow: 1px 1px red; }
offset-x: offset-y:
box-shadow: offset-x offset-y blur spread color
.example1 { box-shadow: 0 0 1px 1px red; }
inset: blur: spread:
#example1 { text-shadow: 2px 2px 10px red; } #example2 { text-shadow: 1px 1px 10px red, 10px 10px 10px orange, 15px 15px 10px yellow, 20px 20px 10px green, 25px 25px 10px blue, 30px 30px 10px purple; }
Build gradients with css
.linear-example1 { background-image(linear-gradient(red, orange, yellow, green, blue, indigo, violet)); } .linear-example2 { background-image(linear-gradient(right, red, orange, yellow, green, blue, indigo, violet)); } .linear-example3 { background-image(linear-gradient(bottom right, red, orange, yellow, green, blue, indigo, violet)); }
.radial-example1 { background-image(radial-gradient(circle cover, red, orange, yellow, green, blue, indigo, violet)); } .radial-example2 { background-image(radial-gradient(0 0, circle, red, orange, yellow, green, blue, indigo, violet)); } .radial-example3 { background-image(radial-gradient(0 50%, circle, red, orange, yellow, green, blue, indigo, violet)); }
CSS3 allows multiple background images
.example { background-image: url('../images/html5-features.png'), url('../images/sky.jpg'); }
Enhance our Women in Computing web site to use HTML5 & CSS3
If you get stuck, take a look at the example for inspiration
Allow property changes in CSS values to occur smoothly over a specified duration
Create some awesome effects without any JavaScript
the names of CSS properties that should be transitioned
.example1 { transition-property: background-color; }
set to all to transition all CSS properties
.example2 { transition-property: all; }
the number of seconds or milliseconds a transition animation should take to complete
.example1 { transition-duration: 2s; }
2s duration
delay transitions from the moment a trigger happens
.example1 { transition-delay: 0s; } .example2 { transition-delay: 1s; } .example3 { transition-delay: 2s; } .example4 { transition-delay: 3s; }
determines how intermediate values are calculated
.example { transition-timing-function: ease; }
Allow elements rendered by CSS to be transformed in space
scales the element
transform: scale(sx[, sy]);
rotates the element degrees around its origin
transform: rotate(angle);
move element using x and y coordinates
transform: translate(ax[, ay]);
the x and y origin for transformation
transform-origin: x-offset y-offset;
animate transitions from one CSS style configuration to another
@-webkit-keyframes background-color{ from{background-color:slategray} to{background-color:black} } #background-color { -webkit-animation: background-color 1s infinite alternate;background-color:slategray}
A media type and at least one expression that limits the style sheets' scope by using media features, such as width, height, and color
background-color: grey; @media screen and (min-width: 300px) and (max-width: 600px) { background-color: red; } @media screen and (min-width: 900px) and (max-width: 1200px) { background-color: blue; }
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
Frequently used in responsive web design
Example: Build ResponsivelyHTML5 IE enabling script
Enhance our Women in Computing web site to use HTML5 & CSS3
If you get stuck, take a look at the example for inspiration