html5 と svg で考える、これからの画像アクセシビリティ

Post on 17-Jul-2015

19.124 Views

Category:

Design

9 Downloads

Preview:

Click to see full reader

TRANSCRIPT

SVG MANIAXScalable Vector Graphics

Vol. 3

松田直樹CCO, Web Designer

SVGの特徴って?

画像 であり、 文書 である

XML文書だから

すべての図形や画像は "要素" となる

path 要素 line 要素 rect 要素

circle 要素 ellipse 要素 polygon 要素 image 要素

text 要素

Lorem ipsum dolor

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://

www.w3.org/1999/xlink" viewBox="0 0 100 100">

<path d="M0,42.197C0,18.892,18.892,0,42.197 ... "/>

<rect x="0" y="20" width="10" height="10"/>

<polygon points="81.098,61.017 88.796,76.614 ... "/>

<text>Lorem ipsum dolor</text>

</svg>

文書であるということは

テキストノードを含めることができる

マシンリーダブル

アクセシビリティを確保できる

HTML5 + inline SVGにおける

アクセシビリティ

SVGの最大の利点?

画像の「中身」を

アクセシブルにできる

画像といえば、代替テキスト

JPEG や PNG の代替テキスト

alt="ハンバーガー"

longdesc="http://example.com/desc1"

SVG の代替?テキスト

<svg viewBox="0 0 100 100"> <title> ハンバーガー </title> <desc> ハンバーガーのフラットな イラストアイコン </desc> … </svg>

SVG の代替テキスト

title 要素 / desc 要素

それぞれの コンテナ要素 や グラフィックス要素 には個別に、

desc 要素, またはテキストのみの説明を与える title 要素,

あるいはそれらの両方を指定することができる。

SVG内のそれぞれの要素にも使える

<g> <title>ハンバーガー</title> <desc>…</desc> </g>

<g> <title>ホットドッグ</title> <desc>…</desc> </g>

<g> <title>ドーナッツ</title> <desc>…</desc> </g>

<rect x="10" y="10" width="20" height="20"> <title>すごく四角い</title> <desc>…</desc> </rect>

<g x="10" y="10"> <title>たくさん丸い</title> <desc>…</desc> <path …> <circle …> <circle …> <circle …> </g>

図形などの要素にも グループなどのコンテナ要素にもグループ化

<svg viewBox="0 0 100 100">

<title>フードメニュー</title> <desc>当店のフードメニューのイラストアイコン</desc>

<g> <title>ハンバーガー</title> <desc>人気No.1。オリジナルのパティとトマトソース…</desc> </g>

<g> <title>ホットドッグ</title> <desc>カリッと焼いた粗挽きソーセージのホット…</desc> </g>

<g> <title>ドーナッツ</title> <desc>外はカリッ。中はモチモチ。そこそこヘルシー…</desc> </g>

… </svg>

でも、title 要素と desc要素、

スクリーンリーダーが読んでくれない

SVG のスクリーンリーダー対応

role 属性 / aria-* 属性 を使いましょう

WebコンテンツおよびWebアプリケーション、

特にRIAを

あらゆるユーザにとってよりアクセシブルにするもの

SVG のスクリーンリーダー対応

role 属性 aria-* 属性

要素の「役割」を定義する

要素の「状態」を定義する

<svg viewBox="0 0 100 100"

role="img" aria-labelledby="title desc">

<title id="title">ハンバーガー</title>

<desc id="desc">ハンバーガーのフラットなイラストアイコン</desc>

… </svg>

role と aria-labelledby で対応しましょう

<svg viewBox="0 0 100 100"

role="img" aria-labelledby="title desc">

<title id="title">ハンバーガー</title>

<desc id="desc">トマトとレタス、チーズのハンバーガーのイラスト</desc>

… </svg>

SVG のスクリーンリーダー対応

ハンバーガー トマトとレタス、チーズのハンバーガーのイラスト イメージ

SVG のスクリーンリーダー対応

<g role="img" aria-labelledby="title1 desc1"> <title id="title1">四角</title> <desc id="desc1">黒い正方形</desc> <rect width="100" height="100"/> </g> <g role="img" aria-labelledby="title2 desc2"> <title id="title2">丸</title> <desc id="desc2">黒い正円</desc> <circle cx="170" cy="50" r="50"/> </g> <g role="img" aria-labelledby="title3 desc3"> <title id="title3">三角</title> <desc id="desc3">黒い正三角形</desc> <polygon points="0,207 50,120 99.999,207 "/> </g> <g role="img" aria-labelledby="title4 desc4"> <title id="title4">星形</title> <desc id="desc4">黒い星</desc> <polygon points="169.987,112.12 185.438,143.427 219.987,148.447 194.987,172.816 200.889,207.226 169.987,190.98 139.086,207.226 144.987,172.816 119.987,148.447 154.536,143.427"/> </g>

SVG のスクリーンリーダー対応

<g role="img" aria-labelledby="title1 desc1"> <title id="title1">四角</title> <desc id="desc1">黒い正方形</desc> <rect width="100" height="100"/> </g> <g role="img" aria-labelledby="title2 desc2"> <title id="title2">丸</title> <desc id="desc2">黒い正円</desc> <circle cx="170" cy="50" r="50"/> </g> <g role="img" aria-labelledby="title3 desc3"> <title id="title3">三角</title> <desc id="desc3">黒い正三角形</desc> <polygon points="0,207 50,120 99.999,207 "/> </g> <g role="img" aria-labelledby="title4 desc4"> <title id="title4">星形</title> <desc id="desc4">黒い星形</desc> <polygon points="169.987,112.12 185.438,143.427 219.987,148.447 194.987,172.816 200.889,207.226 169.987,190.98 139.086,207.226 144.987,172.816 119.987,148.447 154.536,143.427"/> </g>

四角 黒い正方形 イメージ

丸 黒い正円 イメージ

三角 黒い正三角形 イメージ

星形 黒い星 イメージ

• SVGのtitle要素は、仕様書のとおりだと、hoverでツールチップ表示されるべき(UAによる実装)

• ***.svg という単体のSVGファイルでは、まったくスクリーンリーダーで読まれない

小ネタ

小ネタ

Authors should always provide a ‘title’ child element to the outermost svg element within a stand-alone SVG document. The ‘title’ child element to an ‘svg’ element serves the purposes of identifying the content of the given SVG document fragment. Since users often consult documents out of context, authors should provide context-rich titles.

独立した SVG 文書の 最も外側の svg 要素 に対し

常に、 title 要素を子要素として与えるべきである

http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements

Scalable Vector Graphics (SVG) 1.1 (Second Edition)

詳細は早川さんのブログにてhttp://blog.e-riverstyle.com/2014/12/svg.html

SVGの中でHTMLを使う

SVGの中で

「見出し」的なテキストを使いたい

SVG の中でHTMLを使う

foreignObject 要素 + HTMLの要素 が使える

foreignObject要素は、グラフィックの描画に、

SVGとは異なる名前空間の要素(HTMLなど)を

用いることができる要素

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

例えば、こんなグラフ

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

<g>

<title id="point-sato"">230点</title>

<text x="450" y="370">佐藤</text>

<rect x="450" y="123" width="70" height="230"

role="img" aria-labelledby="point-sato"/>

</g>

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

このままだと、全部読み上げられるのに

時間がかかってしまう

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

お、なんかこいつ、見出しっぽい

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

<g>

<title id="point-sato">86点</title>

<foreignObject x="76" y="273" width="40" height="25">

<h3>佐藤</h3>

</foreignObject>

<rect x="67" y="116 width="55" height="130"

role="img" aria-labelledby="point-sato"/>

</g>

0

30

60

90

120

150

渡辺田中高橋鈴木佐藤

VoiceOver等の

「見出し間スキップ」機能が使える

DEMO

アクセシブルにできるのは分かったが

どんな画像に向いているのか?

こんな一枚画像までもがアクセシブルに

地図もそのままアクセシブルに

凝ったナビゲーションもアクセシブルに

今後のブラウザ対応にも期待

SVG Accessibility API Mappings 草案公開http://www.w3.org/TR/2015/WD-svg-aam-1.0-20150226/

画像の「中身」を アクセシブルにできること

SVGの最大の利点

松田直樹

ありがとうございました

SVG MANIAXScalable Vector Graphics

Vol. 3

top related