This talk discusses standards evolution, HTML5 and CSS3 in detail. Starting with the history of HTML and CSS, it goes on to show how HTML5 and CSS3 were developed, why they were necessary, the problems they aim to solve, what the main new features are and why they are so useful, and how we can start using these features in the real world, right now. It also provides advice for the discerning web standards gentleman.
20. But things don't
stand still!
•People started to use HTML/
CSS for things they weren't
intended for
•Browsers implemented new
features
•New browsing devices
appeared
22. CSS3
•CSS3 work started around
1999
•Over 40 modules as of
03-2011
•Some are more stable than
others
23. HTML5
•W3C decided the future was
XHTML
•This didn't go down well with
the web community
•HTML5 started by WHATWG
around 2004
•Adopted by W3C 2008
24. HTML5 and CSS3
designed to
•Be backwards compatible
•Compete with plugin tech
•Be more in keeping with what
we are actually doing
•Add more efficient, powerful
features
•Be as accessible as possible
30. There's many reasons a
gentleman should care
•More consistency
•Less presentational/
unsemantic markup
•Better built in accessibility
•Less JavaScript/Photoshop
•Less Flash
•More tipples
31. Shut the computer and pick up a
newspaper every once in a while.
http://www.therulesofagentleman.com/no-12/
33. A typical web site
<div id="header"></div>
<div id="nav"></div>
<div id="main">
<div class="article"></div>
<div class="article"></div>
...
</div>
<div id="footer"></div>
34. Common classes and IDs
Google and Opera carried out
studies:
• http://code.google.com/webstats/
2005-12/classes.html
• http://devfiles.myopera.com/articles/
572/idlist-url.htm
• http://devfiles.myopera.com/articles/
572/classlist-url.htm
38. Where does this leave the
humble Div?
Use it for anything that isn’t
covered by the other new
elements, and is just a general
grouping for styling purposes.
39. Lax syntax?
•You don't need to quote
attribute values
•Or self-close empty elements
•You can minimise attributes
•You can mix lower and upper
case
•& have a really small doctype
40. Lax syntax?
•Thismore accurately reflects
what we REALLY do
•Not what the W3C thinks we
should do
•The browser fills things in for
you
•HTML5 defines error handling
41. The line between confidence and
arrogance is very thin.
http://www.therulesofagentleman.com/no-6/
50. Web fonts also rock
•Download custom fonts along
with your web pages
•Solve our typography
nightmares, without having to
worry about hackish solutions
like siFR and Cufon
51. Animations
You can smoothly animate
features on your page using
CSS3:
•Based on state changes
(transitions)
•Or independent of anything
else (animations)
52. Animations
<canvas> also allows animation
•But it has a lot more power,
and its own problems
•And it's JS
•Different use cases...
53. Learn from those who came before
you.
http://www.therulesofagentleman.com/no-23/
55. Designers don't like
scripting!
•HTML5 and CSS3 gives you a
whole bunch of behaviour
•Complicated form controls
•Form validation
•Animation (see earlier)
•Showing/hiding
58. var str = "";
Who wants to write this
var elements = document.getElementsByTagName('input');
s**t?
// loop through all input elements in form
for(var i = 0; i < elements.length; i++) {
// check if element is mandatory; ie has a pattern
var pattern = elements.item(i).getAttribute('pattern');
if (pattern != null) {
var value = elements.item(i).value;
// validate the value of this element, using its defined
pattern
var offendingChar = value.match(pattern);
// if an invalid character is found or the element was left
empty
59. HTML5 gives you this
<input type=text required
pattern="[A‐z]{1,20} [A‐z]{1,20}">
61. Showing/hiding
using :target
<li><a href="#target">Click me to target the
paragraph below</a></li>
<p id="target">I am targeted by the above link
when clicked</p>
p:target {
// I am applied to the paragraph when the link
// is clicked
}
62. Opening the door for a lady is not
optional, and will never go out of
style ~ Andy Rutledge
Please Note: This means any door.
http://www.therulesofagentleman.com/no-28/
68. Controlling layouts
•Media queries: apply CSS
depending on media features
eg resolution, screen width
and height.
•Viewport: customise initial
display of pages on mobile
•Multi-column layout: easy
columns
79. We've looked at spec
development
•Specs don't matter if browsers
don't have consistent support
•Browser adoption doesn't
matter if we don't care...
•...though more often this isn't
exactly the case
•Often we are not in the
position to use new features
80. Stuck between a rock and a
hard place?
•Older browsers don't support
this stuff
•Some of us are forced to
support them
•Many clients are still obsessed
with "pixel perfect layouts"
across all browsers
81. However
•Even IE9 supports most of it
•Most of it degrades gracefully
•You can work around many
problems (eg Modernizr,
Selectivizr)
•Depending on your client
needs
82. Besides
•"identicalacross every
browser" is outdated
•Impossible considering the
range of devices on the Web
•Flash doesn't work on iDevices
•IE6 is 10 years old