CSUN 2017
"All browsers support SVG"
(With some exceptions, and no real specification :( )
img
elementimg
element
<img src="foo.svg" alt="…" longdesc="….html">
Best results for accessible information
<body>
<p>Using SVG inline:</p>
<svg width="300" height="200">
<!-- some svg -->
</svg>
<!-- some more HTML... -->
Exposed role of image/diagram in Firefox, IE
<svg width="2.5em" height="1em">
</svg>
Exposed role of image
<svg role="img" width="250" height="100">
<!-- some SVG… -->
</svg>
title
First one exposed as accessible name
<svg role="img" width="250" height="100">
<title>Rectangle</title>
<rect width="100%" height="100%" fill="#81b;"/>
</svg>
title
+ ARIAFirst one exposed as accessible name
<svg role="img" aria-labelledby="title" width="250" height="100">
<title id="title">Rectangle</title>
<rect width="100%" height="100%" fill="#81b;"/>
</svg>
title
s need ARIA<svg width="250" height="100">
<rect aria-labelledby="purple"
fill="#81b;" width="10" height="10" >
<title id="purple">Purple</title> </rect>
<rect aria-labelledby="green"
fill="#0b0;" x="200" y="90" width="10" height="10">
<title id="green">Green</title> </rect>
</svg>
desc
<svg aria-labelledby="title" role="img"
width="250" height="100">
<title id="title">Rectangle</title>
<desc>Violet rectangle on its side</desc>
<rect width="100%" height="100%" fill="#820bbb;"/>
</svg>
desc
+ ARIA<svg role="img" width="50" height="10">
<title id="title">Rectangle</title>
<rect aria-describedby="desc"
width="50" height="10" fill="#81b;"
<desc id="desc">Violet rectangle on its side</desc>
</rect>
</svg>
text
Available to assistive technologies as plain text
<svg width="250" height="100">
<text x="50" y="25">Tequila</text>
</svg>
(Internal links broken in Safari :( )
<svg width="400" height="400">
<a xlink:href="#foo">
<rect x="118" y="25" height="20" width="90" fill="#81b"/>
<text x="120" y="33">Tequila</text>
</a>
<text x="30" y="330" id="foo">Makes me happy</text>
</svg>
Works everywhere now \o/
<svg width="250" height="100">
<rect role="button" tabindex="0"
fill="#81b" width="100%" height="100%">
<text x="120" y="33">Foo</text>
</rect>
<!-- (Hey! Make the button WORK …) -->
</svg>
<svg width="100" height="30">
<defs>
<g id="rect">
<desc>A rectangle on its side</desc>
<rect width="20%" height="10%"/>
</g>
</defs>
<!-- … continued on next slide …>
<!-- continuing the same SVG -->
<use xlink:href="#rect" fill="blue">
<title>blue</title></use>
<use xlink:href="#rect" x="100" y="50" fill="green"/>
<title>green</title></use>
</svg>
<svg role="table"><title>Bar chart example</title>
<text y="20" role="heading" aria-level="1">stuff</text>
<g role="rowgroup">
<text role="rowheader" y="75">Tuesday</text>
<rect role="cell" aria-labelledby="value-1-1"…
<title id="value-1-1">477</title>
<!-- etc etc -->
Adapt to zoom:
onzoom
currentScale
vector-effect="non-scaling-stroke"
<style>
:focus path, :focus polygon,
:focus ellipse { stroke-width: 4}
g g:hover path, g g:hover polygon,
g g:hover ellipse { stroke-width: 4}
:focus text, g g:hover text
{ stroke: black; stroke-width: .5}
</style>
<line x1="300" x2="300" y1="300" y2="350">
<animate attributeName="y1" to="280"
dur="2s" begin="heat.click" fill="freeze"/>
<animate attributeName="y1" from="280" to="200"
dur="5s" begin="heat.click+7s" fill="freeze"/>
</line>
<!-- ... -->
<g id="heat" role="button" tabindex="0">
id.click
27s
id.end+13s
accesskey="f"
(Interaction with the web is hard ;( )
var heat=document.querySelector("#heat");
heat.addEventListener("keydown",start);
function start(e){
if (e.keyCode == 32) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click",true,true,window,0,0,0,0,0,false,false,false,false,0,null);
heat.dispatchEvent(evt);}
}
<g aria-live="polite">
<text x="250" y="95">Status:</text>
<text id="idle" x="250" y="120">Idle
<animate attributeName="visibility" to="hidden"
begin="heat.click" dur="30s"/></text>
<text id="heating-ice" visibility="hidden"
x="250" y="120">Heating ice
<animate attributeName="visibility"
to="visible" begin="heat.click" dur="2s"/></text>
SVG would be even better