Download - HTML5 Semantics

Transcript
Page 2: HTML5 Semantics

HTML Semantics

SHAY HOWEwww.shayhowe.com – @shayhowe

@shayhowe

Page 3: HTML5 Semantics

WHY SEMANTICS?

@shayhoweHTML Semantics

Page 4: HTML5 Semantics

WHY SEMANTICS?Unambiguous, shared meaningGive content significant value and meaning. AccessibilityProvide information to assistive technologies.

Search & globalizationImprove visibility and internalization.

InteroperabilityAllow exchange and use of information.

@shayhoweHTML Semantics

Page 5: HTML5 Semantics

STRUCTURAL

@shayhoweHTML Semantics

Page 6: HTML5 Semantics

STRUCTURAL ELEMENTS

@shayhowe

HeaderIntroductory or navigational aids.

NavSection with navigational links.

ArticleIndependently reusable content.

SectionGenerically, thematic grouping.

AsideTangentially related content.

FooterClosing related content.

HTML Semantics

Page 7: HTML5 Semantics

STRUCTURAL ELEMENTS<body>    <header>        <nav>...</nav>    </header>    <article>        <section>...</section>    </article>    <aside>...</aside>    <footer>...</footer></body>

@shayhoweHTML Semantics

Page 8: HTML5 Semantics

ARIA ROLES<body>    <header  role="banner">        <nav  role="navigation">...</nav>    </header>    <article  role="article">        <section  role="region">...</section>    </article>    <aside  role="complementary">...</aside>    <footer  role="contentinfo">...</footer></body>

@shayhoweHTML Semantics

Page 9: HTML5 Semantics

TEXT

@shayhoweHTML Semantics

Page 10: HTML5 Semantics

BOLDING TEXTB<b>...</b>Stylistically offset without importance. Strong<strong>...</strong>Strong emphasis.

@shayhoweHTML Semantics

Page 11: HTML5 Semantics

ITALICIZING TEXTI<i>...</i>Alternative voice or tone. Em<em>...</em>Stressed emphasis.

@shayhoweHTML Semantics

Page 12: HTML5 Semantics

UNDERLINING TEXTU<u>...</u>An unarticulated annotation. Ins<ins  cite="#"  datetime="2011-­‐08-­‐24">...</ins>Text added to the document.

@shayhoweHTML Semantics

Page 13: HTML5 Semantics

STRIKING TEXTS<s>...</s>No longer accurate or relevant. Del<del  cite="#"  datetime="2011-­‐08-­‐24">...</del>Text deleted from the document.

@shayhoweHTML Semantics

Page 14: HTML5 Semantics

NAVIGATION & ACTIONSNav<nav>...</nav>Major navigational links. Menu<menu>...</menu>Group of controls, commonly within web apps.

@shayhoweHTML Semantics

Page 15: HTML5 Semantics

HYPERLINKSInline<p><a  href="http://www.shayhowe.com/">Shay      Howe</a>  is  a  front-­‐end  web  designer  and      developer.</p> Block<a  href="http://www.shayhowe.com/"><h1>Shay  Howe</h1><p>Front-­‐end  web  designer  and  developer.</p>

</a>

@shayhoweHTML Semantics

Page 16: HTML5 Semantics

HYPERLINK DOWNLOADBoolean<a  href="logo.png"  download>    Company  Logo</a> With a value<a  href="logo.png"  download="Company-­‐Logo">    Company  Logo</a>

@shayhoweHTML Semantics

Page 17: HTML5 Semantics

HYPERLINK REL ATTRIBUTEPossible Values

<a  href="legal.html"  rel="copyright">    Privacy  Policy/Terms  of  Use</a>

@shayhowe

licensenextprevprevsection

subsectionstartstylesheettag

alternateappendixbookmarkchaptercontents

contentscopyrightglossaryhelpindex

HTML Semantics

Page 18: HTML5 Semantics

CITATIONS Cite<p><cite><a  href="#">Steve  Jobs</a></cite>  by      Walter  Isaacson  is  truly  inspirational.</p>Specifically a reference to a title of work.

@shayhoweHTML Semantics

Page 19: HTML5 Semantics

QUOTATIONSQ<p><a  href="#">Steve  Jobs</a>  once  said,  <q      cite="#">Stay  hungry,  stay  foolish.</q></p>Short, inline quotation.

Blockquote<blockquote  cite="#">    <p>Design  is  a  funny  word...</p>    <p><a  href="#">Steve  Jobs</a>  in  <cite><a          href="#">Fortune  Magazine</a></cite></p></blockquote>Longer, extended quotation.

@shayhoweHTML Semantics

Page 20: HTML5 Semantics

LANGUAGE SUPPORTEnglishq:lang(en)  {    quotes:  "\201C"  "\201D"  "\2018"  "\2019";}“English quote with a ‘nested’ quote.”

Frenchq:lang(fr)  {    quotes:  "\AB"  "\BB";}«French quote with a «nested» quote.»

@shayhoweHTML Semantics

Page 21: HTML5 Semantics

HIGHLIGHTING TEXT<h1>Search  results  for  'chicago'</h1><ol>    <li>        <a  href="http://www.shayhowe.com/">Shay  is              from  <mark>Chicago</mark>.</a>    </li></ol>

@shayhoweHTML Semantics

Page 22: HTML5 Semantics

GAUGING SCALE<meter>7  out  of  10  stars</meter>

<meter  max="10">7  stars</meter>

<meter  min="0"  max="105"  low="5"  high="65"        optimum="45"  value="47">The  car  is  moving  at      a  decent  average  mile  per  hour.</meter>

@shayhoweHTML Semantics

Page 23: HTML5 Semantics

INDICATING PROGRESSYou  are  <progress>50%</progress>  complete.

<progress  min="0"  max="100"  value="50">Hold      tight,  your  getting  there.</progress>

@shayhoweHTML Semantics

Page 24: HTML5 Semantics

REPRESENTING TIME<time  datetime="15:00">3pm</time>

<time  datetime="2011-­‐08-­‐24">August  24th,  2011</time>

<time  datetime="2011-­‐08-­‐24T15:00">August  24th,    2011  at  3pm</time>

<time  datetime="2011-­‐08-­‐24"  pubdate>August    24th,  2011</time>

<time>2011-­‐08-­‐24</time>

@shayhoweHTML Semantics

Page 25: HTML5 Semantics

HIDING CONTENT Good<div  hidden>...</div>Element, and contents, are not yet, or no longer relevant.

Not as Good<div  style="display:  none;">...</div>No value, commonly read by assistive technology.

@shayhoweHTML Semantics

Page 26: HTML5 Semantics

USING PSEUDO SELECTORSHTML<p>Hello  <abbr  title="and">&amp;</abbr>      welcome...</p>

CSSp:first-­‐letter  {    font-­‐size:  40px;}abbr[title="and"]  {    font:  italic  18px  Baskerville,  serif;    }

Hello & welcome...

@shayhoweHTML Semantics

Page 27: HTML5 Semantics

LIST

@shayhoweHTML Semantics

Page 28: HTML5 Semantics

SETTING A START<ol  start="30">    <li>30</li>    <li>31</li>    <li>32</li>    <li>33</li></ol>

<ol  start="30">    <li>30</li>    <li>31</li>    <li  value="40">40</li>    <li>41</li></ol>

@shayhoweHTML Semantics

Page 29: HTML5 Semantics

REVERSING A LIST<ol  reversed>    <li>4</li>    <li>3</li>    <li>2</li>    <li>1</li></ol>

<ol  reversed>    <li>4</li>    <li>3</li>    <li  value="30">30</li>    <li>29</li></ol>

@shayhoweHTML Semantics

Page 30: HTML5 Semantics

IMAGES

@shayhoweHTML Semantics

Page 31: HTML5 Semantics

FIGURE & FIGCAPTION<figure>    <img  src="shay.jpg"  height="300"  width="200">    <figcaption>Shay  Howe,  the  Man</figcaption></figure>

<figure>    <img  src="june.jpg"  height="200"  width="200">    <img  src="july.jpg"  height="200"  width="200">    <figcpation>Summer  Months</figcaption></figure>

@shayhoweHTML Semantics

Page 32: HTML5 Semantics

ALT VS. TITLE TEXTAlternate TextReplace an image, should it not be available Title TextProvide a description of an image

<img  src="june.jpg"  height="200"  width="200"      alt="June  is  a  summer  month  with  30  days,      coming  after  May  and  before  July"      title="Month  of  June">

@shayhoweHTML Semantics

Page 33: HTML5 Semantics

VIDEO

@shayhoweHTML Semantics

Page 34: HTML5 Semantics

VIDEO<video  src="movie.webm"  height="390"      width="640"></video>

<video  src="movie.webm"  height="390"      width="640"  poster="poster.jpg"    preload="auto"  autoplay  controls  loop  muted></video>

@shayhoweHTML Semantics

Page 35: HTML5 Semantics

VIDEO FALLBACKS<video  height="390"  width="640"  poster="poster.jpg">    <source  src="movie.webm"        type='video/webm;  codecs="vp8,  vorbis"'>    <source  src="movie.mp4"        type='video/mp4;  codecs="avc1.4D401E,  mp4a.40.2"'>    <source  src="movie.ogv"        type='video/ogg;  codecs="theora,  voris"'>    <object  type="application/x-­‐shockwave-­‐flash"          data="player.swf">

<img  src="poster.jpg"  alt=""  title="Movie  Poster"><p><strong>Download  Movie:</strong>    <a  href="movie.webm"  download>WebM</a>,    <a  href="movie.mp4"  download>MPEG-­‐4</a>,    <a  href="movie.ogv"  download>Ogg</a>.</p>

</object></video>

@shayhoweHTML Semantics

Page 36: HTML5 Semantics

VIDEO TRACKS<video  height="390"  width="640"  poster="poster.jpg">    <source  src="movie.webm"        type='video/webm;  codecs="vp8,  vorbis"'>    <source  src="movie.mp4"        type='video/mp4;  codecs="avc1.4D401E,  mp4a.40.2"'>    <source  src="movie.ogv"        type='video/ogg;  codecs="theora,  voris"'>    <track  kind="captions"  label="English  Captions"          src="english-­‐cc.vtt"  srclang="en"  default>    <track  kind="subtitles"  label="English  Subtitles"          src="english-­‐st.vtt"  srclang="en">    <track  kind="subtitles"  label="French  Subtitles"          src="french-­‐st.vtt"  srclang="fr"></video>

@shayhoweHTML Semantics

Page 37: HTML5 Semantics

AUDIO

@shayhoweHTML Semantics

Page 38: HTML5 Semantics

AUDIO<audio  src="song.mp3"></audio>

<audio  src="song.mp3"  autoplay  controls  loop      preload="auto"></audio>

@shayhoweHTML Semantics

Page 39: HTML5 Semantics

AUDIO FALLBACKS<audio  controls>    <source  src="song.oga"        type='audio/ogg;  codecs="vorbis"'>    <source  src="song.m4a"        type='audio/mp4;  codecs="mp4a.40.2"'>    <p><strong>Download  Song:</strong>

<a  href="song.oga"  download>Ogg</a><a  href="song.m4v"  download>ACC</a>.</p>

</audio>

@shayhoweHTML Semantics

Page 40: HTML5 Semantics

IFRAMES

@shayhoweHTML Semantics

Page 41: HTML5 Semantics

FALLBACK<iframe  src="page.html"  height="200"    width="600">    <a  href="page.html">View  embedded  webpage.</a></iframe>

@shayhoweHTML Semantics

Page 42: HTML5 Semantics

SANDBOX ATTRIBUTENo form submissionNo JavaScriptNo external link targetsRestricted local accessNo plug-ins

@shayhoweHTML Semantics

Page 43: HTML5 Semantics

SANDBOX VALUESallow-formsAllow form submissions

allow-scriptsAllow scripts to execute

allow-same-originTreat content as if it is from the local server

allow-top-navigationAllow links to open in other browsing contexts

@shayhoweHTML Semantics

Page 44: HTML5 Semantics

SANDBOX VALUESBoolean<iframe  src="page.html"  sandbox>

Single Value<iframe  src="page.html"  sandbox="allow-­‐forms">

Multiple Values<iframe  src="page.html"  sandbox="allow-­‐scripts  allow-­‐same-­‐origin">

@shayhoweHTML Semantics

Page 45: HTML5 Semantics

SEAMLESS ATTRIBUTELinks open in parent windowCSS and JS are inheritedScreen readers read content inline

<iframe  src="page.html"  seamless>    <a  href="page.html">View  embedded  webpage.</a></iframe>

@shayhoweHTML Semantics

Page 46: HTML5 Semantics

FORMS

@shayhoweHTML Semantics

Page 47: HTML5 Semantics

COLOR<input  type="color"  name="color">

@shayhoweHTML Semantics

Page 48: HTML5 Semantics

DATE & TIMEdate:  2012-­‐05-­‐21datetime:  2012-­‐05-­‐24T12:00:00+01month:  2012-­‐05time:  12:00:00week:  2012-­‐W21

<input  type="datetime-­‐local"    name="event">

@shayhoweHTML Semantics

Page 49: HTML5 Semantics

EMAIL<input  type="email"  name="email"  multiple>

@shayhoweHTML Semantics

Page 50: HTML5 Semantics

NUMBER<input  type="number"  name="cost"  min="10"      max="100">

@shayhoweHTML Semantics

Page 51: HTML5 Semantics

RANGE<input  type="range"  name="rating"  min="0"      max="10">

@shayhoweHTML Semantics

Page 52: HTML5 Semantics

TEL<input  type="tel"  name="phone">

@shayhoweHTML Semantics

Page 53: HTML5 Semantics

SEARCH<input  type="search"  name="query">

@shayhoweHTML Semantics

Page 54: HTML5 Semantics

URL<input  type="url"  name="website">

@shayhoweHTML Semantics

Page 55: HTML5 Semantics

DATALIST<input  type="text"  name="city"  list="cities"><datalist  id="cities">    <option  value="Chicago">    <option  value="Los  Angeles">    <option  value="New  York"></datalist>

@shayhoweHTML Semantics

Page 56: HTML5 Semantics

AUTOMATION Autocomplete<form  action="foo"  autocomplete="off"><input  type="text"  name="destination"      autocomplete="off">

Autofocus<input  type="text"  name="destination"      autofocus>

@shayhoweHTML Semantics

Page 57: HTML5 Semantics

ASSISTANCE Placeholder<input  type="text"  name="destination"      placeholder="Chicago">

Title<input  type="text"  name="destination"      title="Please  enter  your  destination.">

@shayhoweHTML Semantics

Page 58: HTML5 Semantics

DISABLING INPUTS Inputs<input  type="text"  name="destination"  disabled>

Groups of inputs<fieldset  disabled>    <input  type="text"  name="destination">    <input  type="number"  name="cost"></fieldset>

@shayhoweHTML Semantics

Page 59: HTML5 Semantics

INCREMENTAL STEPS Numbers<input  type="number"  name="cost"  min="10"      max="100"  step="2"><input  type="range"  name="rating"  min="0"      max="10"  step=".5">

Time<input  type="date"  name="event"      min="2012-­‐05-­‐01"  max="2012-­‐08-­‐32"  step="2">

@shayhoweHTML Semantics

Page 60: HTML5 Semantics

VALIDATION Required<input  type="text"  name="destination"  required>

Pattern<input  type="tel"  name="phone"    pattern="^[0-­‐9]+[\-­‐  ]*[0-­‐9]+$">

Maxlength<input  type="url"  name="website"    maxlength="100">

@shayhoweHTML Semantics

Page 61: HTML5 Semantics

VALIDATIONHTML<input  type="text"  name="destination"  required>

CSSinput:required:after  {    color:  red;    content:  "\002A";}input:required:valid:after  {    color:  green;    content:  "\2713";}

@shayhoweHTML Semantics

Page 62: HTML5 Semantics

GET INVOLVED

@shayhoweHTML Semantics

Page 63: HTML5 Semantics

QUESTIONS?Thank you!

@shayhoweHTML Semantics


Top Related