On Github jannypie / html5-intro
Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Stuff to keep in mind!
Labels that define and separate parts of your markup into elements
<img />
<h1> </h1>
<p> </p>Element
A single markup object from opening to closing tags
<p>A paragraph.</p>
<div>Sidebar content</div>Attribute
Name/value pairs within the opening tag that provide additional information
Examples: class=" ", id=" ", href=" ", src=" "
<!-- Example of an image element with attributes --> <img src="logo.png" title="My Logo" alt="company logo" />
<!-- Example of a div element with attributes --> <div id="header" class="full-width" />ID
An element attribute that should always be unique to that single element and not re-used
ClassAn element attribute that can take one or more values, separated by spaces; Classes can be used on any number of elements
An element with a rectangular shape that takes up the entire width of its parent, creating a "block"
Begins on a new line, and following elements also begin on a new line
Examples: <div>, <h1> </h1>, <p> </p>
Inline-Level ElementAn element that falls "inline" with the text surrounding it, without creating new breaks in the flow
Examples: <a> , <span> </span>, <img />
HTML5 is the W3C’s set of standards for the next version of HTML, which had not been officially updated since HTML4 in 1999.
What has happened in the web since the early days?
What were some new challenges the web faced?
Too much to cover in our time together
But here are some highlights:
Gives some old elements semantic meaning and separates them from presentation (e.g. b, i, strong, em)
<b>Bolded text</b> <i>Italics text</i>
Became
<strong>Heavier text</strong> <em>Emphasized text</em>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html>
HTML5 Doctype also requires charset declaration
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Example document</title> </head> <body> <p>Example paragraph</p> </body> </html>
Minimum information required to ensure that a browser renders using standards mode
Basic HTML examples:
What were we seeing before?
<body> <div id="header"> <h1>Hi, I'm a header!</h1> <div id="nav"> <ul> <li><a href="foo">foo</a></li> <li><a href="bar">bar</a></li> </ul> </div> </div> <div id="main"> <div class="article">foo</div> <div class="article">bar</div> </div> <div id="footer">Hi, I'm a footer!</div> </body>Well, it's better than using tables
But, this is
<div id="header"></div>
<div class="nav"></div>
<div id="footer"></div>
Also known as "div-itis"
To a browser, none of these elements mean anything, or relate to any other part
W3C looked at a large number of websites to see how people were using these divs, then created new semantic elements.
<header id="site-header"></header>
<header class="article-header"></header>
<nav id="site-links"></nav>
<body> <header></header> <main></main> <footer></footer> </body>
<footer id="site-footer"></footer>
<footer class="article-footer"></footer>
<section id="about-me"></section> <section id="contact-us"></section>
Example article markup from nytimes.com
The document outline is the structure of a document, generated by the document’s headings, form titles, table titles, and any other appropriate landmarks to map out the document.
This table of contents could then be used by assistive technology to help the user, or be parsed by a machine like a search engine to improve search results.
It also helps treat the plague of div-itis!
To talk about browser compatibility
HTML5 IE enabling script
<!--[if lt IE 9]> <script src="html5shiv.js"></script> <![endif]-->polyfill (n): a JavaScript shim that replicates the standard API for older browsers
Forms used to be a series of <input>s with maybe a <textarea> and a <input type="submit">
<input type=" "> now has new options
Placeholders
Can be placed on input or textarea elements
Gives hint to user for data entry
<input type="email" placeholder="name@email.com">
Required
Can be used on input, select, and textarea
Won't let the form be submitted if not filled out!
<input type="name" required>
Audio and video are first class citizens in HTML5
HTML4 forced us to use embedded elements
<embed src="MyVideo.mp4"/>
No browser control over play/pause, sound, or anything
Useful as a replacement for flash on mobile devices
Flash makes mobile devices sad :(
The Dream
The video element was created to make it unnecessary to use plugins to display video content on your pages.
The idea is to simplify and streamline video content delivery.
<video src="demo.mp4" type="video/mp4"> Your browser does not support the video element. </video>
The Reality
If you want to support ALL browsers and ALL video encodings, you will still need a plugin as a last-resort fall back plan.
This is because not all browsers read video the same way, and older browsers (like IE<9) don't support the video element at all.
In reality it looks a bit like this
<video id="video" controls preload="metadata" poster="img/poster.jpg"> <source src="my-video.mp4" type="video/mp4"> <source src="my-video.webm" type="video/webm"> <source src="my-video.ogg" type="video/ogg"> <object type="application/x-shockwave-flash" data="flash-player.swf?videoUrl=video/my-video.mp4" width="1024"> <img alt="my-video" src="img/my-video-poster.jpg" title="No video playback possible"/> </object> </video>
<audio controls> <source src="music.mp3" type="audio/mpeg"/> <source src="music.aac" type="audio/mp4" /> <source src="music.ogg" type="audio/ogg"/> <!-- now include flash fall back --> </audio>
The first step is to add a canvas element to your HTML. Make sure you give it an id:
<canvas id="myCanvas" width="400" height="400"> Your browser doesn’t support Canvas. </canvas>
Unfortunately, everything else (all the cool stuff) is actually in JavaScript and outside the scope of this class
Use HTML5 elements to markup up a sample blog post or news article.
Bonus
Time permitting, also include a comment section with HTML5 comment form