css: the boring bits
DESCRIPTION
My talk at London Web Standards on 12th March 2012. Looking at new and (possible) future features of the less glamorous areas of the CSS spec.TRANSCRIPT
![Page 1: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/1.jpg)
Peter Gasston@StopsAtGreen
![Page 2: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/2.jpg)
CSS3:The boring bits.
X
![Page 3: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/3.jpg)
Boring things*The Matrix Revolutions
The Lord of the Rings filmsColdplay
Apple vs Android
*Removed images of dubious provenance
![Page 4: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/4.jpg)
Exciting CSS
![Page 5: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/5.jpg)
.bar { filter: sepia(0.5); }
Filters.foo { filter: grayscale(1); }
![Page 6: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/6.jpg)
background-image: cross-fade( url('foo.png'), url('bar.png'), 50%);
cross-fade()
![Page 7: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/7.jpg)
An interesting paradox:The more boring a CSS feature is, the
more excited I get when someone does something cool with it.
![Page 8: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/8.jpg)
Backgrounds& Borders
http://dev.w3.org/csswg/css4-background/
![Page 9: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/9.jpg)
background-position: h n v n;background-position:right 20px bottom 10%;
Four values allows more flexible placing of background images.
![Page 10: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/10.jpg)
border-corner-shape: foo;border-corner-shape: bevel;
![Page 11: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/11.jpg)
border-clip: [x y];border-clip: [visible invisible];border-clip: 10px 1fr 10px;
Custom border shapes; clip the border to show the areas you want.
![Page 12: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/12.jpg)
@namespace "http://www.w3.org/1999/xhtml"; @namespace svg "http://www.w3.org/2000/svg";
Namespaces
http://www.w3.org/TR/css3-namespace/
![Page 13: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/13.jpg)
a { color: #F00; }svg|a { color: #00F; }
![Page 14: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/14.jpg)
@font-face { font-family: foo; src: url('foo.woff'); unicode-range: U+31-33;}
unicode-range
http://www.w3.org/TR/css3-fonts/#unicode-range-desc
![Page 15: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/15.jpg)
![Page 16: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/16.jpg)
<meta name="viewport" content="width=320">
Device Adaptation
http://dev.w3.org/csswg/css-device-adapt/
![Page 17: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/17.jpg)
@viewport { width: 320px; }
![Page 18: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/18.jpg)
@viewport { foo: bar;}
@media screen and (max-width:320px) { @viewport { foo: baz; }}
![Page 19: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/19.jpg)
Values
http://www.w3.org/TR/css3-values/
![Page 20: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/20.jpg)
body { font-size: 10px; }h1 { font-size: 2.4em; }h1 span { font-size: 0.9167em; }h1 span { font-size: 2.2rem; }
rem
The rem unit is always relative to the root font-size, not that of its parent as em is.
![Page 21: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/21.jpg)
vh, vw, vmin
100vw
div { width: 25vw; }
vh = viewport height, vw = viewport width, vmin = either vh or vw, whichever is smaller. It’s a length measure that’s relative to the viewport, not the parent.
![Page 22: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/22.jpg)
attr(title)attr(data-color color)
attr()
The attr() value will now accept more than strings, as it currently does. You can specify the type to be color, url, number, and more.
![Page 23: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/23.jpg)
div::before { content: 'foo'; }div { content: replaced 'foo'; }
It’s proposed that you be able to replace content in any element, rather than just ::after or ::before.
![Page 24: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/24.jpg)
calc()width: calc(75% - 20px)
![Page 25: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/25.jpg)
cycle()em { font-style: cycle(italic,normal); }
Will cycle through the values depending on inherited values. For example, em will be have font-style: italic if its parent is normal, or normal if its parent is italic.
![Page 26: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/26.jpg)
Selectors
http://dev.w3.org/csswg/selectors4/
![Page 27: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/27.jpg)
:targete { color: #F00; }e:target { color: #00F; }
:target is applied to an internal link which the user has followed; e.g. <a href=”#foo”>
![Page 28: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/28.jpg)
:dir()e:dir(rtl) {}
Used for internationalised sites; rtl, ltr.
![Page 29: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/29.jpg)
:not()e:not(.foo) {}
![Page 30: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/30.jpg)
:nth-child(odd):not(:last-child):nth-*
![Page 31: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/31.jpg)
:matches().foo .bar h1, .foo .bar h2, .foo .bar h3 {}.foo .bar :matches(h1,h2,h3) {}
![Page 32: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/32.jpg)
:any-link:local-link
:link, :visited
:any-link means any link, regardless of its visited state; :local-link is for links on the same domain.
![Page 33: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/33.jpg)
:nth-column():nth-last-column()
:column()
Applied to, for example, tables. Will possible work for grid layouts too.
![Page 34: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/34.jpg)
:future
:past:current
Selectors based on temporal position, such as combined with audio, video, screen readers.
![Page 35: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/35.jpg)
label:hover /for/ inputE /x/ F
A bit complicated this; the x value is an attribute of E which is equal to the id value of F. Best example is <label for=”foo”> <input id=”foo”>
![Page 36: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/36.jpg)
$E > F
The parent selector!!! The element E has styles applied if it contains element F.
![Page 37: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/37.jpg)
:root { data-foo: #F00;}h1 { color: data(foo);}
http://dev.w3.org/csswg/css-variables/
CSS Variables. Uses the data- pattern from the HTML5 data attributes. Scoped by applying to elements.
![Page 38: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/38.jpg)
Boring = Exciting
![Page 39: CSS: The Boring Bits](https://reader034.vdocuments.net/reader034/viewer/2022051313/549c805bac7959ec2a8b4743/html5/thumbnails/39.jpg)
Still available.Still not boring.
http://thebookofcss3.com