Semantic HTML

By

Licensed under Creative Commons Attribution 4.0 International

Goals

  • Thoughtful approach to composing HTML
  • Treat HTML pages as documents
  • Better overall front end code

Real world document: publication

Publication example

Has structure!

  • Front page
  • Table of contents
  • Introduction
  • Chapters
  • Conclusion
  • References
Publication - front page
Publication - front page (elements marked up)
Publication - chapter
Publication - chapter (elements marked up)

Other elements

  • Header & footer
  • Footnotes
  • Asides
  • Definitions
  • Tables
  • Formulas
  • ...

World Wide Web

Made up of documents

Blog example

Plenty of elements

Blog example (marked up)

Deep nesting

3D view of a Youtube page (deep element nesting illustrated)

High dynamicity

Twitter feed (high dynamicity of the Web example)

Many representations

Boston Globe responsive website

Still documents

Sitemap example

Lots of them!

Internet map

Hypertext

Fundamental concept behind WWW

The Idea

Plenty of texts with links between them WorldWideWeb browser

Extend, connect, share

hypertext

The language?

HyperText Markup Language

The Web Triforce

The Web Troforce: HTML, CSS, JavaScript

HTML documents

Composed of elements


<html> <!-- ROOT ELEMENT -->
    <head>
        <!--  METADATA: title, author, description, etc. -->
    </head>

    <body>
        <!--  PAYLOAD CONTENT -->
    </body>
</html>
                    

Element order

MATTERS!

  • Search engines
  • Mobile browsing
  • Keyboard navigation
  • Find in page

Element order

Adobe Developer Connection page

Element order

Adobe Developer Connection page - suboptimal element ordering

Element order

Adobe Developer Connection page - better element ordering

Links

Essence of the World Wide Web

1. Hyperlinks


<a href="/cats.html">Please don't break my href!</a>
                        

2. Links to external resources


<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/touch-icon.png">
<link rel="stylesheet" href="/styles/main.css">
                        
… used to augment the current document, generally automatically processed by the user agent.

Other uses of link

Author

Author link is used by search engines

Site search

Search link enables searching the website before visiting it!

News feed

Feed link allows content grabbing by feed readers

Also...

  • Alternate language
  • Previous/next page
  • License
  • PDF version

See the spec for more

HTML5

  • Simplified syntax
  • New elements and attributes
  • New API
  • Precisely defined parsing rules,
    including error behavior

New elements

  • section, article, aside, nav
  • header, footer
  • figure, figcaption
  • time, meter, progress, mark
  • audio, video, canvas

Full list

Not enough elements?

Not enough elements?

Are you sure?

Not enough elements?

Are you sure?

Use the class attribute

Sections

Структура документа в HTML5

Each section is like a mini-document

New input types

search, email, url, tel,number,
range, color
date, month, week,
time, datetime, datetime-local

See examples

Input: not just text!


<input type="file" accept="image/*;capture=camera">
        <!-- also: camcorder, microphone -->
                        
Demo

Benefits of semantic markup

Better read by programs

  • Screen readers
  • Search engines
  • Sharing tools
  • Content clippers
  • News grabbers
  • ...

Easier to change presentation

Content is like water...

Reusability across projects


<section class="carousel">
    <h1>Featured Content</h1>

    <article class="slide">
        <h2>Slide Title</h2>
        <div class="slide-content"> ... </div>
    </article>

    <article class="slide">
        <h2>Slide Title</h2>
        <div class="slide-content"> ... </div>
    </article>
</section>
                        
More great patterns from Anthony Ticknor

Improves your JS too

Algorithms + Data Structures = Programs (book cover)

Demo: css-tricks.com

CSS Tricks - 4:3 screen

Mobile view

CSS Tricks - mobile view

Mobile view (with navigation)

CSS Tricks - mobile view (with navigation)

Print

CSS Tricks - print

Evernote Clipped Article

CSS Tricks - Evernote Clipped Article

Search result snippet (article)

Search result snippet for article

Search result snippet (home)

Search result snippet for home page

Google Plus Share

Article shared on Google+

Takeaways

Be responsible about IA*

Your HTML = your IA

Hyperlinks are important!

Don't break their functionality!

Experiment, make mistakes

Follow the standards

Stuff gets obsolete

Let's talk!

http://dpashk.com

dpashk@gmail.com

Attributions