Miguel Costa
"A serious and good philosophical work could be written consisting entirely of jokes."
Navigable, Accessible, Informative
The PSP’s web browser is – charitably – pathetic. It is slow, frequently runs out of memory, and can only open 3 tabs at a time.
But the GOV.UK pages are written in simple HTML. They are designed to be lightweight and will work even on rubbish browsers. They have to. This is for everyone. -- Terence Eden
You can solve many problems
with the right html elements,
without too much ARIA
Semantic HTML is...
Meaning
Ok, but what does "meaning"... mean?
Semantic HTML is...
Semantic HTML is...
NOT Presentation
<center>Centered</center>
<blink>Blinking</blink>
<marquee>Sliding</marquee>
<font>Custom Font</font>
source: webFX
source: searchengineland
"No, really,don't use it!" - W3C
The elements of the first web page:
Semantic HTML is...
REALLY old!
there was different information on different computers, but you had to log on to different computers to get at it (...) sometimes you had to learn a different program on each computer. Often it was just easier to go and ask people when they were having coffee…
Tim Berners-Lee, World Wide Web Foundation
"The benefit (...) stems from what should be the driving goal of any web page: the desire to communicate"
-- Lifewire
Improve web page navigation and usability
with just HTML and (very few) attributes)
Revisit OLD tags
Meet NEW tags
Unique (identifiable) parts of a page
Try using a web page without the mouse and find out!
Heading (h4)
Heading (h5)
NOT a Heading
block has role="note"
A tale of two titles
from: Semantics - MDN Web Docs Glossary (adapted)
<h1 id="title">
Top level heading
</h1>
<span
id="title"
style="font-size: 32px; margin: 21px 0;"
>
Top level heading?
</span>
They look the same, but are they both...
If the page had a table of contents, would that element be in it?
Would it make sense to separate this block from its context? Would it be 'indexed'?
"Articles are not meant to be considered landmark elements" -- Scott O'Hara
Is it a part of a page with its own title?
No? Div
Dunno? Div
Yes? Section (maybe?)
Div
Everything
do not set any of these roles: they're the defaults
Element | Role |
---|---|
header | banner |
footer | contentinfo |
aside | complementary |
main | main |
article | article |
nav | navigation |
section | region (generic) |
h1-h6 | heading |
Aside = Gabriel Alves (a nice complement to the main narration, but not actually part of it)
banner
(or header)
NOT
a banner!
The button element represents a button. If the element is not disabled, then the user agent should allow the user to activate the button.
- W3C Button Page (in Association of controls and forms)
An anchor is a piece of text which marks the beginning and/or the end of a hypertext link.
- W3C Anchors Markup Page (in Association of controls and forms)
Links impact SEO crawlers, who consider REAL links to other pages (improving SEO)
(in "modern" browsers)
Links can have a 'download' attribute to "download" a file instead of opening it
... but should you?
<a
href="somekind/of/document.pdf"
download
>
Some kind of document
</a>
Anchors - curiosities
<HEAD>
...other head information...
<TITLE>Chapter 5</TITLE>
<LINK rel="prev" href="chapter4.html">
<LINK rel="next" href="chapter6.html">
</HEAD>
source: W3C Links
Link tips - referring to next and previous pages
<div>s with a purpose
As defined by the <abbr title="World Health Organization">WHO</abbr>, ...
<abbr title="telephone">Tel.</abbr>
Acronyms and abbreviations
source: MDN
<article>
<!-- ... -->
<footer>
Wanna contact the author?
<address>
<ul>
<li>Address: 42nd Street, New York, USA</li>
<li>
<a href="mailto:totallynotfakeemail@totallynotfake.fake">
totallynotfakeemail@totallynotfake.fake
</a>
</li>
<li>
<a href="tel:+9999999999999">
9999999999999 (THOUSAAA-AAAAND)
</a>
</li>
</ul>
</address>
</footer>
</article>
In what language is this content in?
<html lang='pt'>
<!-- ... -->
<p>
Temos o Goku
</p>
<p lang='es'>
Tenemos a Goku
</p>
<!-- ... -->
</html>
Portuguese by default
Spanish (this quote)
A Spanish, a French and a German walk into an English bar...
english quotes
!= german quotes
!= french quotes
source: technology.gov.uk
<input
type="text"
inputmode="numeric"
pattern="[0-9]*"
>
enables numeric virtual keyboard
Issues with
localization, SEO, sharing
Is there a version for this page in my language?
<head>
<!-- English-speaking alternatives -->
<link rel="alternate" href="http://example.com/en" hreflang="en" />
<!-- US-specific alternative -->
<link rel="alternate" href="http://example.com/en" hreflang="en-us" />
<!-- when no better option is available -->
<link rel="alternate" href="http://example.com/pt" hreflang="x-default" />
</head>
Sources: Moz
images, icons, video, code... <figure> it out!
title, alt, label & aria
alt - textual representation of media
(image, video)
<!-- with this focused, a screen reader will read the url -->
<img src="http://placekitten.com/300/200">
<!-- this picture has a description -->
<img alt="A kitten" src="http://placekitten.com/300/200">
<!-- has no focus, ideal for icons in labels or background images -->
<img alt="" src="http://placekitten.com/300/200">
title, alt, label & aria
aria-label, aria-labelledby
"The aria-label attribute is used to define a string that labels the current element. Use it in cases where a text label is not visible on the screen. If there is visible text labeling the element, use aria-labelledby instead." - MDN
<span class="nav-toggle"> ☰ Menu </span>
source: HTMLHell, recipe 11
Can be announces as 'Trigram from heaven Menu'
is menu expanded or not?
what role?
what if I click Space OR Enter?
How to focus?
source: Stellify
(fixed)
<button class="nav-toggle" aria-expanded="false">
<span aria-hidden="true">☰</span> Menu
</button>
source: HTMLHell, recipe 11
Roles
<div role="status" aria-live="polite">
<!-- ... -->
</div>
Status and Alert
<div role="alert" aria-live="assertive">
<!-- ... -->
</div>
via: MDN
aria-live podem ser omitidos (teoricamente)
<p role="alert">
<strong>Form updated</strong>, your changes were also saved
</p>
<p role="note">
<strong>Warning</strong>: don't forget to save before you leave!
</p>
"the alert role is (...) for dynamic content (...) is equivalent to aria-live="assertive" aria-atomic="true"
Textual elements, abbreviations, localization
What to they mean?
<strong>er and dominant!
What matters most
strong importance (the rest is either details or complements to what's highlighted, most important steps, the actual title of a chapter, etc.)
seriousness (warning/caution notices)
urgency (should be seen before the rest)
A <em>problem</em>
<em>YOU</em>
You can see it in his eyes!
<em>NOW</em>
<em>phasize the intended meaning
<!-- focus on the fact they're cats -->
<p><em>Cats</em> are cute animals.</p>
<!-- enforce the fact that they ARE cute! A counter-argument, maybe? -->
<p>Cats <em>are</em> cute animals.</p>
<!-- enforce what cats are... maybe someone said they're MEAN? -->
<p>Cats are <em>cute</em> animals.</p>
<!-- enforce that cats are ANIMALS (not plants or humans, or whatever...) -->
<p>Cats are cute <em>animals</em>.</p>
<!-- you can (super)emphasize inside an already emphasized element-->
<p><em>Cats are <em>cute</em> animals!</em></p>
changes the meaning, but isn't actually more important than the rest
"(...) alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text"... (WhatWG)
<i> "sound" different
Examples
He's got this <i lang="fr">je ne sais quoi</i>...
"offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is bold text"... (W3C)
<b> class player
Examples
"a last resort when no other element is more appropriate" (WhatWG)
<!DOCTYPE HTML>
<html>
<head>
<title>About elks</title>
</head>
<body>
The truth about elks.
</body>
</html>
Source: Javascript Info
Fun content I can't group anywhere else
(in this presentation)
The paragraph tag (yes, in upper case) was intended to separate paragraphs, not wrap them.
Remy Sharp, in (Why Some HTML is "optional")
Title attribute in fields
<!-- even though there's no visible label,
there's a title attribute that provides audio description -->
<input id="spellbox" title="Type fleurppel here to continue.">
source: Chromevox Tutorial
By Miguel Costa