html/css tips to improve the accessibility of your websites

210
HTML/CSS TIPS TO IMPROVE THE ACCESSIBILITY OF YOUR WEBSITES Ivo Gomes @ivogomes www.ivogomes.com Quinta-feira, 10 de Novembro de 11

Upload: ivo-gomes

Post on 17-May-2015

14.534 views

Category:

Technology


0 download

DESCRIPTION

My Accessibility talk for Codebits 2011

TRANSCRIPT

Page 1: HTML/CSS tips to improve the accessibility of your websites

HTML/CSS TIPS TOIMPROVE THE ACCESSIBILITY OF YOUR WEBSITES

Ivo Gomes@ivogomes www.ivogomes.com

Quinta-feira, 10 de Novembro de 11

Page 2: HTML/CSS tips to improve the accessibility of your websites

Why should I care?

Quinta-feira, 10 de Novembro de 11

Page 3: HTML/CSS tips to improve the accessibility of your websites

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 4: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 5: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

Accessible websites are ugly and boring

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 6: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

Accessible websites are ugly and boring

Accessibility is expensive and difficult

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 7: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

Accessible websites are ugly and boring

Accessibility is expensive and difficult

Offering a text-only version is good enough

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 8: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

Accessible websites are ugly and boring

Accessibility is expensive and difficult

Offering a text-only version is good enough

Validation equals accessibility

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 9: HTML/CSS tips to improve the accessibility of your websites

Accessibility is just for blind people

Accessible websites are ugly and boring

Accessibility is expensive and difficult

Offering a text-only version is good enough

Validation equals accessibility

If it works with a screen reader it is accessible

ACCESSIBILITYMYTHS

Quinta-feira, 10 de Novembro de 11

Page 10: HTML/CSS tips to improve the accessibility of your websites

OK, so what can I do?

Quinta-feira, 10 de Novembro de 11

Page 11: HTML/CSS tips to improve the accessibility of your websites

1.Quinta-feira, 10 de Novembro de 11

Page 12: HTML/CSS tips to improve the accessibility of your websites

ENLARGE

Quinta-feira, 10 de Novembro de 11

Page 13: HTML/CSS tips to improve the accessibility of your websites

ENLARGEYOUR

Quinta-feira, 10 de Novembro de 11

Page 14: HTML/CSS tips to improve the accessibility of your websites

ENLARGEYOUR

FONTQuinta-feira, 10 de Novembro de 11

Page 15: HTML/CSS tips to improve the accessibility of your websites

ENLARGE YOURFONT

Don’t use tiny 10px

or 12 px text size

Try 16px

or even more...

Quinta-feira, 10 de Novembro de 11

Page 16: HTML/CSS tips to improve the accessibility of your websites

Pro tip: Try reading your website when seated 1 meter away from the screen

Quinta-feira, 10 de Novembro de 11

Page 17: HTML/CSS tips to improve the accessibility of your websites

USE RELATIVE FONT-SIZES

html { font-size: 62.5%; }

body { font-size: 1.6em; = 16px (sort of)}

Quinta-feira, 10 de Novembro de 11

Page 18: HTML/CSS tips to improve the accessibility of your websites

USE RELATIVE FONT-SIZES

html { font-size: 62.5%; }

body { font-size: 1.6em; = 16px (sort of)}

Beware of the inheritance!

Quinta-feira, 10 de Novembro de 11

Page 19: HTML/CSS tips to improve the accessibility of your websites

USE RELATIVE FONT-SIZES

body { font-size: 1.6em; = 16px}

h1 { font-size: 2em; = 32px (not 20px)}

!body > h1

h1 font size is 2em x 1.6em

Quinta-feira, 10 de Novembro de 11

Page 20: HTML/CSS tips to improve the accessibility of your websites

USE RELATIVE FONT-SIZES

body { font-size: 16px; font-size: 1.6rem; = 16px}

h1 { font-size: 20px; font-size: 2rem; = 20px}

Quinta-feira, 10 de Novembro de 11

Page 21: HTML/CSS tips to improve the accessibility of your websites

2.Quinta-feira, 10 de Novembro de 11

Page 22: HTML/CSS tips to improve the accessibility of your websites

INCREASE YOURLINE-HEIGHT

Quinta-feira, 10 de Novembro de 11

Page 23: HTML/CSS tips to improve the accessibility of your websites

INCREASE YOURLINE-HEIGHTLorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et felis malesuada massa fermentum faucibus sit amet sed augue. Aliquam aliquam auctor diam, sed varius nunc tempus in. Fusce vel egestas massa. Quisque sit amet libero risus, ac viverra enim.

line-height: normal;

Quinta-feira, 10 de Novembro de 11

Page 24: HTML/CSS tips to improve the accessibility of your websites

INCREASE YOURLINE-HEIGHTLorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et felis malesuada massa fermentum faucibus sit amet sed augue. Aliquam aliquam auctor diam, sed varius nunc tempus in. Fusce vel egestas massa. Quisque sit amet libero risus, ac viverra enim.

line-height: 1.4;

Quinta-feira, 10 de Novembro de 11

Page 25: HTML/CSS tips to improve the accessibility of your websites

3.Quinta-feira, 10 de Novembro de 11

Page 26: HTML/CSS tips to improve the accessibility of your websites

PROVIDESKIP-LINKS

Quinta-feira, 10 de Novembro de 11

Page 27: HTML/CSS tips to improve the accessibility of your websites

PROVIDESKIP-LINKS

Skip links provide a way for users to jump directly to the page content, without having to go through all the navigation links.

Quinta-feira, 10 de Novembro de 11

Page 28: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 29: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 30: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 31: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 32: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 33: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 34: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 35: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 36: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 37: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 38: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 39: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 40: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 41: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 42: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 43: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 44: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 45: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 46: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 47: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 48: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 49: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 50: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 51: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 52: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 53: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 54: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 55: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 56: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 57: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 58: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 59: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 60: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 61: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 62: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 63: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 64: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 65: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 66: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 67: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 68: HTML/CSS tips to improve the accessibility of your websites

PROVIDESKIP-LINKS

Most people choose to hide the skip links. That’s not necessarily bad, if done right.

Quinta-feira, 10 de Novembro de 11

Page 69: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS

#skiplinks { display:none; = BAD}

#skiplinks { text-indent:-9999px; = BAD}

Quinta-feira, 10 de Novembro de 11

Page 70: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS, THE RIGHT WAY

#skiplinks a, #skiplinks a:hover, #skiplinks a:visited { position:absolute; left:0px; top:-500px; width:1px; height:1px; overflow:hidden;}

positions the links outside of the viewport

Quinta-feira, 10 de Novembro de 11

Page 71: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS, THE RIGHT WAY

#skiplinks a:active, #skiplinks a:focus { position:static; width:auto; height:auto; }

shows the links when they are activated (e.g. when navigating with the keyboard)

Quinta-feira, 10 de Novembro de 11

Page 72: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS, THE RIGHT WAY

#skiplinks a:active, #skiplinks a:focus { position:static; width:auto; height:auto; }

shows the links when they are activated (e.g. when navigating with the keyboard)

you can play with the positioning to place the links wherever you want

Quinta-feira, 10 de Novembro de 11

Page 73: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS, THE RIGHT WAY

shows the links when they are activated (e.g. when navigating with the keyboard)

Quinta-feira, 10 de Novembro de 11

Page 74: HTML/CSS tips to improve the accessibility of your websites

HIDING SKIP-LINKS, THE RIGHT WAY

shows the links when they are activated (e.g. when navigating with the keyboard)

Quinta-feira, 10 de Novembro de 11

Page 75: HTML/CSS tips to improve the accessibility of your websites

4.Quinta-feira, 10 de Novembro de 11

Page 76: HTML/CSS tips to improve the accessibility of your websites

TABLESDONE RIGHT

Quinta-feira, 10 de Novembro de 11

Page 77: HTML/CSS tips to improve the accessibility of your websites

TABLESDONE RIGHT

If you must use tables (remember kids, only for tabular data), please do it the right way

Quinta-feira, 10 de Novembro de 11

Page 78: HTML/CSS tips to improve the accessibility of your websites

How?

Quinta-feira, 10 de Novembro de 11

Page 79: HTML/CSS tips to improve the accessibility of your websites

Define a summary and a caption for the table

Quinta-feira, 10 de Novembro de 11

Page 80: HTML/CSS tips to improve the accessibility of your websites

TABLES DONE RIGHT

<table summary=”Example Table”> <caption>Table 1: Company data</caption> <thead> <tr> <th scope=”col”>Company</th> <th scope=”col”>Employees</th> <th scope=”col”>Founded</th> </tr> </thead>

Quinta-feira, 10 de Novembro de 11

Page 81: HTML/CSS tips to improve the accessibility of your websites

Use the th element to specify row and column headers in data tables

Quinta-feira, 10 de Novembro de 11

Page 82: HTML/CSS tips to improve the accessibility of your websites

TABLES DONE RIGHT

<table summary=”Example Table”> <caption>Table 1: Company data</caption> <thead> <tr> <th scope=”col”>Company</th> <th scope=”col”>Employees</th> <th scope=”col”>Founded</th> </tr> </thead>

Quinta-feira, 10 de Novembro de 11

Page 83: HTML/CSS tips to improve the accessibility of your websites

TABLES DONE RIGHT

<tbody> <tr> <th scope=”row”>ACME Inc</th> <td>1000</td> <td>1947</td> </tr> <tr> <th scope=”row”>XYZ Corp</th> <td>2000</td> <td>1973</td> </tr> </tbody></table>

Quinta-feira, 10 de Novembro de 11

Page 84: HTML/CSS tips to improve the accessibility of your websites

AND IT LOOKS LIKE THIS

Source: Bring on the tableshttp://1.gf.gc.sl.pt

Quinta-feira, 10 de Novembro de 11

Page 85: HTML/CSS tips to improve the accessibility of your websites

5.Quinta-feira, 10 de Novembro de 11

Page 86: HTML/CSS tips to improve the accessibility of your websites

DON’T REMOVE THELINK OUTLINE

Quinta-feira, 10 de Novembro de 11

Page 87: HTML/CSS tips to improve the accessibility of your websites

DON’T REMOVE THELINK OUTLINE

Users that rely on the keyboard for navigation need to know which link is focused

Quinta-feira, 10 de Novembro de 11

Page 88: HTML/CSS tips to improve the accessibility of your websites

SO, DON’T EVER, EVER, REMOVE THE OUTLINE OF LINKS

a { outline:none; = BAD}

Quinta-feira, 10 de Novembro de 11

Page 89: HTML/CSS tips to improve the accessibility of your websites

But, but, the outline looks sooooo ugly...

Quinta-feira, 10 de Novembro de 11

Page 90: HTML/CSS tips to improve the accessibility of your websites

OK, YOU CAN REMOVE THE OUTLINE, BUT ONLY WHEN THE LINK IS ACTIVE

a:active { outline:none; }

Quinta-feira, 10 de Novembro de 11

Page 91: HTML/CSS tips to improve the accessibility of your websites

6.Quinta-feira, 10 de Novembro de 11

Page 92: HTML/CSS tips to improve the accessibility of your websites

DON’T CREATEEMPTY LINKS

Quinta-feira, 10 de Novembro de 11

Page 93: HTML/CSS tips to improve the accessibility of your websites

DON’T CREATEEMPTY LINKS

Whenever you put a link on a web page, make sure that it has text content. This may seem incredibly obvious...

Quinta-feira, 10 de Novembro de 11

Page 94: HTML/CSS tips to improve the accessibility of your websites

LINKS WITH NO TEXT CONTENT

<a href="http://example.com/"></a>

<a href="http://example.com/"><img src="image.gif" alt=""></a>

Quinta-feira, 10 de Novembro de 11

Page 95: HTML/CSS tips to improve the accessibility of your websites

THERE, I FIXED IT

<a href="http://example.com/">Link text</a>

<a href="http://example.com/"><img src="image.gif" alt="Link text"></a>

Quinta-feira, 10 de Novembro de 11

Page 96: HTML/CSS tips to improve the accessibility of your websites

7.Quinta-feira, 10 de Novembro de 11

Page 97: HTML/CSS tips to improve the accessibility of your websites

ALWAYS REVEAL THELINK DESTINATION

Quinta-feira, 10 de Novembro de 11

Page 98: HTML/CSS tips to improve the accessibility of your websites

ALWAYS REVEAL THELINK DESTINATION

You should always reveal links that open in a new window or link to a non-HTML document

Quinta-feira, 10 de Novembro de 11

Page 99: HTML/CSS tips to improve the accessibility of your websites

HIGHLIGHT LINKS THAT OPEN IN A NEW WINDOW

a[target="_blank"],a[target="new"] { padding: 0 15px 0 0; background-image: url(images/new_window.gif); background-repeat: no-repeat; background-position: right center;}

Quinta-feira, 10 de Novembro de 11

Page 100: HTML/CSS tips to improve the accessibility of your websites

HIGHLIGHT LINKS THAT OPEN IN A NEW WINDOW

a[target="_blank"],a[target="new"] { padding: 0 15px 0 0; background-image: url(images/new_window.gif); background-repeat: no-repeat; background-position: right center;}

Quinta-feira, 10 de Novembro de 11

Page 101: HTML/CSS tips to improve the accessibility of your websites

LOOK MA, NO IMAGES!

a[target="_blank"]:after,a[target="new"]:after { content: "\00a0 \27A0";}

you can use any other HTML entity instead of this one

Quinta-feira, 10 de Novembro de 11

Page 102: HTML/CSS tips to improve the accessibility of your websites

LOOK MA, NO IMAGES!

a[target="_blank"]:after,a[target="new"]:after { content: "\00a0 \27A0";}

you can use any other HTML entity instead of this one

Quinta-feira, 10 de Novembro de 11

Page 103: HTML/CSS tips to improve the accessibility of your websites

YOU CAN ALSO USE THIS FOR LINKS TO NON-HTML DOCUMENTS

a[href$="pdf"]:after { content: " (PDF)";}

a[href$=".doc"]:after { content: " (DOC)";}

Link text (PDF)

Link text (DOC)

Quinta-feira, 10 de Novembro de 11

Page 104: HTML/CSS tips to improve the accessibility of your websites

AND ALSO FOR LINKS TO EXTERNAL WEBSITES

a[href^="http"]:after { content: "\21D7";}

a[href^="http://yourwebsite.com"]:after,a[href^="http://www.yourwebsite.com"]:after { content: "";}

External links (start with http)

Internal absolute links

Quinta-feira, 10 de Novembro de 11

Page 105: HTML/CSS tips to improve the accessibility of your websites

BUT A BETTER SOLLUTION WOULD BE

<a class="external" href="http://whatever.com">Link text<span> (external link)</span></a>

Link text (external link)

Quinta-feira, 10 de Novembro de 11

Page 106: HTML/CSS tips to improve the accessibility of your websites

BUT A BETTER SOLLUTION WOULD BE

<a class="external" href="http://whatever.com">Link text<span> (external link)</span></a>

a.external span{ position: absolute; left: -5000px; width: 4000px;}

Link text

Quinta-feira, 10 de Novembro de 11

Page 107: HTML/CSS tips to improve the accessibility of your websites

8.Quinta-feira, 10 de Novembro de 11

Page 108: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

Quinta-feira, 10 de Novembro de 11

Page 109: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

When using big linkable blocks, make sure the most important info comes first

Quinta-feira, 10 de Novembro de 11

Page 110: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

When using big linkable blocks, make sure the most important info comes first

Quinta-feira, 10 de Novembro de 11

Page 111: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

When using JavaScript triggered links, you should always provide a href

<a class=”ajax_do_this”> = BAD

Quinta-feira, 10 de Novembro de 11

Page 112: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

When using JavaScript triggered links, you should always provide a href

<a class=”ajax_do_this”> = BAD

<a href=”#” class=”ajax_do_this”> = GOOD

Quinta-feira, 10 de Novembro de 11

Page 113: HTML/CSS tips to improve the accessibility of your websites

MORELINKING TIPS

When using JavaScript triggered links, you should always provide a href

<a class=”ajax_do_this”> = BAD

<a href=”#” class=”ajax_do_this”> = GOOD

<a href=”do-this-if-no-js.html” class=”ajax_do_this”> = BETTER

Quinta-feira, 10 de Novembro de 11

Page 114: HTML/CSS tips to improve the accessibility of your websites

9.Quinta-feira, 10 de Novembro de 11

Page 115: HTML/CSS tips to improve the accessibility of your websites

NON-MOUSENAVIGATION

Quinta-feira, 10 de Novembro de 11

Page 116: HTML/CSS tips to improve the accessibility of your websites

NON-MOUSENAVIGATION

You should always provide navigation feedback for users that don’t or can’t use the mouse

Quinta-feira, 10 de Novembro de 11

Page 117: HTML/CSS tips to improve the accessibility of your websites

NON-MOUSENAVIGATION

You should always provide navigation feedback for users that don’t or can’t use the mouse

This includes the ones that use the keyboard to navigate; their fingers (tactile screens); or other assistive devices

Quinta-feira, 10 de Novembro de 11

Page 118: HTML/CSS tips to improve the accessibility of your websites

Pro tip: Whenever you use :hover, also use :focus

Quinta-feira, 10 de Novembro de 11

Page 119: HTML/CSS tips to improve the accessibility of your websites

Pro tip: Whenever you use :hover, also use :focus

You may want to include the :active state as well to cater for people who use Internet Explorer 7 and earlier, since IE 8 is the first version to support :focus

Quinta-feira, 10 de Novembro de 11

Page 120: HTML/CSS tips to improve the accessibility of your websites

MAKE LINKS FOCUSABLE TO EVERYONE

a:hover{ color:red;}

a:hover,a:focus,a:active{ color:red;}

= BETTER

Quinta-feira, 10 de Novembro de 11

Page 121: HTML/CSS tips to improve the accessibility of your websites

10.Quinta-feira, 10 de Novembro de 11

Page 122: HTML/CSS tips to improve the accessibility of your websites

PARAGRAPHSPACING

Quinta-feira, 10 de Novembro de 11

Page 123: HTML/CSS tips to improve the accessibility of your websites

PARAGRAPHSPACING

Make sure that there is enough spacing between paragraphs

Quinta-feira, 10 de Novembro de 11

Page 124: HTML/CSS tips to improve the accessibility of your websites

PARAGRAPHSPACING

Make sure that there is enough spacing between paragraphs

Like the line-height tip, this greatly improves text readability

Quinta-feira, 10 de Novembro de 11

Page 125: HTML/CSS tips to improve the accessibility of your websites

ADD SOME SPACING BETWEEN PARAGRAPHS

p { margin: 0;}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et felis malesuada massa fermentum faucibus sit amet sed augue. Aliquam aliquam auctor diam, sed varius nunc tempus in. Fusce vel egestas massa. Quisque sit amet libero risus, ac viverra enim.

Quinta-feira, 10 de Novembro de 11

Page 126: HTML/CSS tips to improve the accessibility of your websites

ADD SOME SPACING BETWEEN PARAGRAPHS

p { margin: 10px 0;}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et felis malesuada massa fermentum faucibus sit amet sed augue.

Aliquam aliquam auctor diam, sed varius nunc tempus in. Fusce vel egestas massa. Quisque sit amet libero risus, ac viverra enim.

Quinta-feira, 10 de Novembro de 11

Page 127: HTML/CSS tips to improve the accessibility of your websites

And, as stupid as this tip might be, you should always use <p> for paragraphs

Quinta-feira, 10 de Novembro de 11

Page 128: HTML/CSS tips to improve the accessibility of your websites

WE SEE THIS A LOT

This text is the first paragraph.<br><br>This text is the second paragraph.

<p>This text is the first paragraph.</p><p>This text is the second paragraph.</p>

= WRONG

Quinta-feira, 10 de Novembro de 11

Page 129: HTML/CSS tips to improve the accessibility of your websites

11.Quinta-feira, 10 de Novembro de 11

Page 130: HTML/CSS tips to improve the accessibility of your websites

CHECK THECOLOR CONTRAST

Quinta-feira, 10 de Novembro de 11

Page 131: HTML/CSS tips to improve the accessibility of your websites

CHECK THECOLOR CONTRAST

Check the contrast between the foreground and the background colors

Quinta-feira, 10 de Novembro de 11

Page 132: HTML/CSS tips to improve the accessibility of your websites

CHECK THECOLOR CONTRAST

Check the contrast between the foreground and the background colors

http://snook.ca/technical/colour_contrast/colour.html

or Google for “color contrast checker”

Quinta-feira, 10 de Novembro de 11

Page 133: HTML/CSS tips to improve the accessibility of your websites

CHECK THECOLOR CONTRAST

Quinta-feira, 10 de Novembro de 11

Page 134: HTML/CSS tips to improve the accessibility of your websites

CHECK THECOLOR CONTRAST

Quinta-feira, 10 de Novembro de 11

Page 135: HTML/CSS tips to improve the accessibility of your websites

12.Quinta-feira, 10 de Novembro de 11

Page 136: HTML/CSS tips to improve the accessibility of your websites

ABOUT THEALT ATTRIBUTE

Quinta-feira, 10 de Novembro de 11

Page 137: HTML/CSS tips to improve the accessibility of your websites

ABOUT THEALT ATTRIBUTE

The alt attribute provides a textual alternative to images

Quinta-feira, 10 de Novembro de 11

Page 138: HTML/CSS tips to improve the accessibility of your websites

ABOUT THEALT ATTRIBUTE

The alt attribute provides a textual alternative to images

But you shouldn’t add an alternative text to every image in your website

Quinta-feira, 10 de Novembro de 11

Page 139: HTML/CSS tips to improve the accessibility of your websites

Waaa? No alt text?

Quinta-feira, 10 de Novembro de 11

Page 140: HTML/CSS tips to improve the accessibility of your websites

I didn’t say that

Quinta-feira, 10 de Novembro de 11

Page 141: HTML/CSS tips to improve the accessibility of your websites

You must ALWAYS add the alt attribute

Quinta-feira, 10 de Novembro de 11

Page 142: HTML/CSS tips to improve the accessibility of your websites

BUT SOMETIMES IT’S BETTER IF IT’S BLANK

<img src=”boobs.png” alt=”Boobs” />

Include alternative text only when the image content is relevant

Quinta-feira, 10 de Novembro de 11

Page 143: HTML/CSS tips to improve the accessibility of your websites

BUT SOMETIMES IT’S BETTER IF IT’S BLANK

<img src=”boobs.png” alt=”Boobs” />

<img src=”useless-decorative-picture.png” alt=”” />

Include alternative text only when the image content is relevant

If the image is irrelevant, the alt should be there, but blank

Quinta-feira, 10 de Novembro de 11

Page 144: HTML/CSS tips to improve the accessibility of your websites

13.

Quinta-feira, 10 de Novembro de 11

Page 145: HTML/CSS tips to improve the accessibility of your websites

ABOUT THETITLE ATTRIBUTE

Quinta-feira, 10 de Novembro de 11

Page 146: HTML/CSS tips to improve the accessibility of your websites

ABOUT THETITLE ATTRIBUTE

The title attribute should be used to provide extra information about some element on the page

Quinta-feira, 10 de Novembro de 11

Page 147: HTML/CSS tips to improve the accessibility of your websites

So, stop duplicating the link text inside the title attribute

Quinta-feira, 10 de Novembro de 11

Page 148: HTML/CSS tips to improve the accessibility of your websites

USING THE TITTLE ATTRIBUTE THE RIGHT WAY

<a href=”article.html” title=”I like icecream”>I like Icecream</a> = BAD

Screen readers will just repeat the link text twice

Quinta-feira, 10 de Novembro de 11

Page 149: HTML/CSS tips to improve the accessibility of your websites

USING THE TITTLE ATTRIBUTE THE RIGHT WAY

<a href=”article.html” title=”I like icecream”>I like Icecream</a> = BAD

<a href=”article.html” title=”Select an option to see the corresponding items”>Select an option</a>

Screen readers will just repeat the link text twice

The title should provide some extra information that is not immediatly visible on the screen

Quinta-feira, 10 de Novembro de 11

Page 150: HTML/CSS tips to improve the accessibility of your websites

14.Quinta-feira, 10 de Novembro de 11

Page 151: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

Quinta-feira, 10 de Novembro de 11

Page 152: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

HTML headings, created with the h1-h6 elements, are very useful and should be used for anything that visually looks or acts like a heading.

Quinta-feira, 10 de Novembro de 11

Page 153: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

Quinta-feira, 10 de Novembro de 11

Page 154: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

Each document should have a logical heading structure that starts at level 1 and doesn’t skip any levels

Quinta-feira, 10 de Novembro de 11

Page 155: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

Each document should have a logical heading structure that starts at level 1 and doesn’t skip any levels

The title of the document’s main content should be a level 1 heading

Quinta-feira, 10 de Novembro de 11

Page 156: HTML/CSS tips to improve the accessibility of your websites

USE HEADINGSFOR TITLES

Each document should have a logical heading structure that starts at level 1 and doesn’t skip any levels

The title of the document’s main content should be a level 1 heading

There should be only one level 1 heading in each document *

Quinta-feira, 10 de Novembro de 11

Page 157: HTML/CSS tips to improve the accessibility of your websites

* WE CAN HAVE MORE THAN ONE <H1> BUT ONLY FOR THE CONTENT TITLE

<h1>Organisation Name</h1><h2>Main menu</h2><ul><li>...</li></ul>

<h2>Sub menu</h2><ul><li>...</li></ul>

<div id="content-primary"><h1>Page title</h1><p>Page content.</p></div>

Quinta-feira, 10 de Novembro de 11

Page 158: HTML/CSS tips to improve the accessibility of your websites

AND THE HEADINGS SHOULD REPRESENT THE DOCUMENT TREE

H1- H2- H2

- H3- H4

- H3- H2

- H3- H2

- H3- H4

- H5

Quinta-feira, 10 de Novembro de 11

Page 159: HTML/CSS tips to improve the accessibility of your websites

15.Quinta-feira, 10 de Novembro de 11

Page 160: HTML/CSS tips to improve the accessibility of your websites

USE THELANG ATTRIBUTE

Quinta-feira, 10 de Novembro de 11

Page 161: HTML/CSS tips to improve the accessibility of your websites

USE THELANG ATTRIBUTE

Screen readers need to know in which language the document is written

Quinta-feira, 10 de Novembro de 11

Page 162: HTML/CSS tips to improve the accessibility of your websites

USE THELANG ATTRIBUTE

Or else, they will use the default English speaker for every text

And if the website is not written in English, well, you can imagine how it would sound like...

Quinta-feira, 10 de Novembro de 11

Page 163: HTML/CSS tips to improve the accessibility of your websites

HOW TO APPLY THE LANG ATTRIBUTE

<html lang="pt-PT">

The entire website is written in portuguese

Quinta-feira, 10 de Novembro de 11

Page 164: HTML/CSS tips to improve the accessibility of your websites

HOW TO APPLY THE LANG ATTRIBUTE

<html lang="pt-PT">

The entire website is written in portuguese

<span lang="en">website</span>

This word or phrase is written in english

Quinta-feira, 10 de Novembro de 11

Page 165: HTML/CSS tips to improve the accessibility of your websites

16.Quinta-feira, 10 de Novembro de 11

Page 166: HTML/CSS tips to improve the accessibility of your websites

SPECIFY BACKGROUND COLORS

Quinta-feira, 10 de Novembro de 11

Page 167: HTML/CSS tips to improve the accessibility of your websites

SPECIFY BACKGROUND COLORS

Remember to specify a solid background color when using background images

Quinta-feira, 10 de Novembro de 11

Page 168: HTML/CSS tips to improve the accessibility of your websites

Hello :)Quinta-feira, 10 de Novembro de 11

Page 169: HTML/CSS tips to improve the accessibility of your websites

Hello :)

If the image fails to load, the text might become unreadable

Quinta-feira, 10 de Novembro de 11

Page 170: HTML/CSS tips to improve the accessibility of your websites

Hello :)

But because we’re smart, we added a solid background color :)

Quinta-feira, 10 de Novembro de 11

Page 171: HTML/CSS tips to improve the accessibility of your websites

SO, ALWAYS APPLY A SOLID BACKGROUND COLOR AS A FALL BACK

#some_div {background: #7A593A url(“wilde.jpg”) no-repeat;

}

Quinta-feira, 10 de Novembro de 11

Page 172: HTML/CSS tips to improve the accessibility of your websites

17.Quinta-feira, 10 de Novembro de 11

Page 173: HTML/CSS tips to improve the accessibility of your websites

WRITE USEFUL PAGE TITLES

Quinta-feira, 10 de Novembro de 11

Page 174: HTML/CSS tips to improve the accessibility of your websites

WRITE USEFUL PAGE TITLES

The page title is what your users will see first when searching for your page/website (either on a search engine, or on the browser’s tab bar and favorites menu)

Quinta-feira, 10 de Novembro de 11

Page 175: HTML/CSS tips to improve the accessibility of your websites

THERE ARE SOME SIMPLE RULES

Reverse the order of the title, i.e. put the document title first and the site name last.

This makes the document title appear first in bookmark lists, browser tabs, and search results.

<title>Page Title - Website Title</title>

Quinta-feira, 10 de Novembro de 11

Page 176: HTML/CSS tips to improve the accessibility of your websites

THERE ARE SOME SIMPLE RULES

Reverse the order of the title, i.e. put the document title first and the site name last.

This makes the document title appear first in bookmark lists, browser tabs, and search results.

vs.

<title>Page Title - Website Title</title>

Quinta-feira, 10 de Novembro de 11

Page 177: HTML/CSS tips to improve the accessibility of your websites

THERE ARE SOME SIMPLE RULES

Use a plain separator character that doesn’t cause confusion

- or |

Keep fancy characters, repetitions and other attempts at graphic design out of page titles

<title>Page Title - Website Title</title><title>Page Title | Website Title</title>

Quinta-feira, 10 de Novembro de 11

Page 178: HTML/CSS tips to improve the accessibility of your websites

THERE ARE SOME SIMPLE RULES

Write titles for humans, not search engines

Don’t put keywords or breadcrumbs on the page title

<title>Page Title - Subcategory - Category - Website Title</title> = BAD

Quinta-feira, 10 de Novembro de 11

Page 179: HTML/CSS tips to improve the accessibility of your websites

18.Quinta-feira, 10 de Novembro de 11

Page 180: HTML/CSS tips to improve the accessibility of your websites

USE LABELS IN FORMS

Quinta-feira, 10 de Novembro de 11

Page 181: HTML/CSS tips to improve the accessibility of your websites

USE LABELS IN FORMS

Use the label element to make your HTML forms accessible

Quinta-feira, 10 de Novembro de 11

Page 182: HTML/CSS tips to improve the accessibility of your websites

USE LABELS IN FORMS

Use the label element to make your HTML forms accessible

The label element can be associated with its form control either implicitly or explicitly.

Quinta-feira, 10 de Novembro de 11

Page 183: HTML/CSS tips to improve the accessibility of your websites

HOW TO USE LABELS IN FORMS

An implicit association is created by putting the form control inside the label element

<label>Your Name: <input type=”text” /></label>

<label><input type=”checkbox” value=”1” /> Pick Me</label>

Quinta-feira, 10 de Novembro de 11

Page 184: HTML/CSS tips to improve the accessibility of your websites

HOW TO USE LABELS IN FORMS

An explicit association is created by giving the label element a for attribute with the same value as the form control’s id attribute.

<label for=”name”>Your Name</label><input type=”text” id=”name” />

<input type=”checkbox” value=”1” id=”option1” /> <label for=”option1”> Pick Me</label>

Quinta-feira, 10 de Novembro de 11

Page 185: HTML/CSS tips to improve the accessibility of your websites

USING LABELS INCREASES THE CLICKABLE AREA

MaleFemale

Without labels

Quinta-feira, 10 de Novembro de 11

Page 186: HTML/CSS tips to improve the accessibility of your websites

USING LABELS INCREASES THE CLICKABLE AREA

MaleFemale

Without labels

Clickable area

Quinta-feira, 10 de Novembro de 11

Page 187: HTML/CSS tips to improve the accessibility of your websites

USING LABELS INCREASES THE CLICKABLE AREA

MaleFemale

With labels

Clickable area

Quinta-feira, 10 de Novembro de 11

Page 188: HTML/CSS tips to improve the accessibility of your websites

19.Quinta-feira, 10 de Novembro de 11

Page 189: HTML/CSS tips to improve the accessibility of your websites

GROUP FORM ELEMENTS

Quinta-feira, 10 de Novembro de 11

Page 190: HTML/CSS tips to improve the accessibility of your websites

GROUP FORM ELEMENTS

Use the fieldset and legend elements to group HTML form controls

Quinta-feira, 10 de Novembro de 11

Page 191: HTML/CSS tips to improve the accessibility of your websites

Do not use the fieldset element if all you want to do is create a graphical

border around some content on a page

Quinta-feira, 10 de Novembro de 11

Page 192: HTML/CSS tips to improve the accessibility of your websites

Use fieldset and legend to group logically related form controls, and always use both elements together

Quinta-feira, 10 de Novembro de 11

Page 193: HTML/CSS tips to improve the accessibility of your websites

GROUP FORM ELEMENTS

Since some screen readers will announce the legend text before each form control, it is important to keep the legend text concise and consider how the legend and label texts will work when put together.

Quinta-feira, 10 de Novembro de 11

Page 194: HTML/CSS tips to improve the accessibility of your websites

COMBINING LEGEND WITH LABELS

<fieldset><legend>Favourite colour</legend><input type="radio" name="fav-col" id="fav-col-1" value="red"><label for="fav-col-1">Red</label>

<input type="radio" name="fav-col" id="fav-col-2" value="green"><label for="fav-col-2">Green</label>

<input type="radio" name="fav-col" id="fav-col-3" value="blue"><label for="fav-col-3">Blue</label></fieldset>

Quinta-feira, 10 de Novembro de 11

Page 195: HTML/CSS tips to improve the accessibility of your websites

GROUP FORM ELEMENTS

Use the optgroup element to group select options

Quinta-feira, 10 de Novembro de 11

Page 196: HTML/CSS tips to improve the accessibility of your websites

GROUPING OPTIONS

<label for="cars">Choose a car brand:</label><select name="cars" id="cars">

<option value="none" selected>None</option><optgroup label="Swedish">

<option value="saab">Saab</option><option value="volvo">Volvo</option>

</optgroup><optgroup label="French">

<option value="citroen">Citroën</option><option value="peugeot">Peugeot</option><option value="renault">Renault</option>

</optgroup></select>

Quinta-feira, 10 de Novembro de 11

Page 197: HTML/CSS tips to improve the accessibility of your websites

GROUPING OPTIONS

<label for="cars">Choose a car brand:</label><select name="cars" id="cars">

<option value="none" selected>None</option><optgroup label="Swedish">

<option value="saab">Saab</option><option value="volvo">Volvo</option>

</optgroup><optgroup label="French">

<option value="citroen">Citroën</option><option value="peugeot">Peugeot</option><option value="renault">Renault</option>

</optgroup></select>

Quinta-feira, 10 de Novembro de 11

Page 198: HTML/CSS tips to improve the accessibility of your websites

20.Quinta-feira, 10 de Novembro de 11

Page 199: HTML/CSS tips to improve the accessibility of your websites

ENLARGE

Quinta-feira, 10 de Novembro de 11

Page 200: HTML/CSS tips to improve the accessibility of your websites

ENLARGEYOUR

Quinta-feira, 10 de Novembro de 11

Page 201: HTML/CSS tips to improve the accessibility of your websites

ENLARGEYOUR

BUTTONSQuinta-feira, 10 de Novembro de 11

Page 202: HTML/CSS tips to improve the accessibility of your websites

ENLARGE YOUR BUTTONS

Make your buttons and clickable elements larger

Quinta-feira, 10 de Novembro de 11

Page 203: HTML/CSS tips to improve the accessibility of your websites

ENLARGE YOUR BUTTONS

Users with limited or low mobility may have dificulty to perform precise movements.

We can make their life easier by enlarging the clickable elements.

Quinta-feira, 10 de Novembro de 11

Page 204: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 205: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 206: HTML/CSS tips to improve the accessibility of your websites

Quinta-feira, 10 de Novembro de 11

Page 207: HTML/CSS tips to improve the accessibility of your websites

If you make your website easier to use for users with special needs

Quinta-feira, 10 de Novembro de 11

Page 208: HTML/CSS tips to improve the accessibility of your websites

You’re also making it easier to use for everyone else

Quinta-feira, 10 de Novembro de 11

Page 209: HTML/CSS tips to improve the accessibility of your websites

Thank You

Quinta-feira, 10 de Novembro de 11

Page 210: HTML/CSS tips to improve the accessibility of your websites

Thank You

@ivogomeshttp://www.ivogomes.com/talks/a11y.pdf

Quinta-feira, 10 de Novembro de 11