by Raphael Oliveira @ Avenue Code
Feb 6th, 2014
Intermediary HTML knowledge
¹: App Cache/Manifest, contenteditable, data-*, role / aria-*, JS APIs such as Geolocation, Session and Local Storages, History/PushState, Audio/Video media, Canvas, Draggable/Droppable. Not covered in this presentation.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
All became
<!DOCTYPE html>
Doctype was simplified and now it's only used to enable Standards Mode for HTML documents.
No enforced trailing slashes on the 'self-closing' elements
<!-- xHTML -->
<img src="path/to/img.ext" alt="" />
<br />
<!-- HTML5 -->
<img src="path/to/img.ext" alt="">
<br>
Elements can have empty attributes without writing =""
<!-- xHTML -->
<input type="text" required="required" autofocus="autofocus" />
<!-- HTML5 -->
<input type="text" required autofocus>
Elements can have attributes without quotes ("")
<!-- xHTML -->
<input type="text" placeholder="username" />
<!-- HTML5 -->
<input type=text placeholder=username >
But quotes are still needed for values which have spaces (like multiple classes) or else the values after the spaces will become (invalid) attributes.
<input type=text class=myForm formPretty coolForm>
<!-- =/= -->
<input type=text class="myForm formPretty coolForm">
No parser normalization
<input type="text" id=" someIdWithSpaces " />
This is no more trimmed/ignored and now count as an error, that is, invalid html.
Used for italic presentation, now represents a span of text in an alternate voice/mood, technical term, phrase in another language or thoughts..
For terms in different languages, it should be used with lang attribute.
Examples:
<p>The <i class="taxonomy">Felis silvestris catus</i> is cute.</p>
<p>The term <i>prose content</i> is defined above.</p>
<p>There is a certain <i lang="fr">je ne sais quoi</i> in the air.</p>
Used for emphasis presentation, now represents a stress emphasis, i.e., something you'd pronounce differently. A statement of fact, with no stress:
<p>Cats are cute animals.</p>
By emphasizing the first word, the statement implies that the kind of animal under discussion is in question (maybe someone is asserting that dogs are cute):
<p><em>Cats</em> are cute animals.</p>
Moving the stress to the verb, one highlights that the truth of the entire sentence is in question (maybe someone is saying cats are not cute):
<p>Cats <em>are</em> cute animals.</p>
Used for bold presentation, now represents a "stylistically offset", that is, something that is only to drawn attention without any other importance, such as keywords, product words in a review, etc.
Use of the b element to highlight key words without marking them up as important:
<p>The <b>Handlebars</b> and <b>requireJS</b> presentations were awesome!</p>
In the following example, objects in a text adventure are highlighted as being special by use of the b element:
<p>You enter a small room. Your <b>sword</b> glows brighter. You feel a chill down your spine, as you sense <b>orcs</b> sleep in the corner wall.</p>
Used for strong emphasis, now represents importance, seriouness and urgent. It does not change the meaning of the phrase like em but highlights the most important part.
<p><strong>Warning.</strong> This dungeon is dangerous. <strong>Avoid the ducks.</strong> Take any gold you find. <strong>Do not take any of the diamonds</strong>, they are explosive and <strong>will destroy anything within ten meters.</strong> You have been warned.</p>
A more daily use, the word "chapter" and the actual chapter number are mere boilerplate, and the actual name of the chapter is marked up with strong:
<h1>Chapter 1: <strong>What HTML 5 aims</strong></h1>
Image from m5designstudio.com
The header element contains introductory information to a section or page. This can involve anything from our normal documents headers (branding information) to an entire table of contents.
<header>
<h1 class="logo">
<a href="#">My Brand</a>
</h1>
<nav>
<!-- navigation contents -->
</nav>
</header>
The nav element is reserved for a section of a document that contains links to other pages or links to sections of the same page. Not all link groups need to be contained within the <nav> element, just primary navigation.
<nav>
<ul>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">Products</a>
</li>
<li>
<a href="#">Another navigation link</a>
</li>
</ul>
</nav>
Aside, represents content related to the main area of the document. This is usually expressed in sidebars that contain elements like related posts, tag clouds, etc - that is, slightly related to the rest of the page. They can also be used for pull quotes.
<section>
<article>
<!-- blog post here -->
</article>
</section>
<aside>
<h4>See also</h4>
<ul>
<li>
<a href="#">Some other post</a>
</li>
</ul>
</aside>
The main content of the body of a document or application. The main content area consists of content that is directly related to or expands upon the central topic of a document or central functionality of an application (just one per page).
<body>
<header></header>
<main>
<section>
</section>
<!-- other sections -->
<aside>
</aside>
</main>
<footer></footer>
</body>
The section element represents a generic document or application section. It acts much the same way a <div> does by separating off a portion of the document.
<main>
<section>
<h2>My website section - about</h2>
<p>content</p>
</section>
<section>
<h2>My website section - contact</h2>
<p>content</p>
</section>
</main>
The article element represents a portion of a page which can stand alone such as: a blog post, a forum entry, user submitted comments or any independent item of content.
<main>
<section>
<article>
<h1>My blog post</h1>
<p>blog content</p>
</article>
<article>
<h1>another blog post</h1>
<p>another blog content</p>
</article>
</section>
</main>
The footer element is for marking up the footer of, not only the current page, but each section contained in the page. So, it’s very likely that you’ll be using the <footer> element multiple times within one page.
<body>
<header></header>
<main>
<section></section>
<aside></aside>
</main>
<footer>
® Copyright 20XX - All rights reserved.
</footer>
</body>
The form has received a significant amount of updates and new items, enabling better control and validation that were previously made using JavaScript as well as better usability.
Notice: Browsers that do not support the new types/attributes will fallback to the standard type="text".
Used for telephone input.
<input type="tel" placeholder="9999-9999" />
Used for e-mail input.
<input type="email" placeholder="your@email.com" />
Used for search input.
<input type="search" placeholder="Search.." />
Used for url input.
<input type="url" placeholder="http://yourwebsite.com" />
Used for date input.
<input type="date" />
Used for month input.
<input type="month" />
Used for week input.
<input type="week" />
Used for time input.
<input type="time" />
Used for datetime-local input. It's a mix of 'date' and 'time' types.
<input type="datetime-local" />
Used for number input.
<input type="number" step="0.5" />
Used for range input.
<input type="range" min="0" max="100" step="0.5" />
Used for color input.
<input type="color" />
There are some attributes that can be used on the inputs.
Also there are some new pseudo-classes available through CSS for styling those new attributes and input states (not covered on this presentation):
<input type="text" id="inputTest" placeholder="a text here" autofocus required pattern="[a-zA-Z]{1,10}" />
#inputTest:invalid {
border:3px solid red;
}
#inputTest:valid {
border:3px solid green;
}
Required input with pattern [a-zA-Z]{1,10} (any character from a-z and A-Z, nothing else) and needs to be between one and 10 characters:
The meter element represents a scalar measurement within a known range, or a fractional value; for example disk usage, the relevance of a query result, or the fraction of a voting population to have selected a particular candidate.
<meter value="50" min="0" max="100" low="40" high="90" optimum="100">50</meter>
val 30
val 60
val 90
The progress element represents the completion progress of a task.
<progress max='100' value='60'><span>60</span>% played</progress>
val 30
val 60
val 90
The progress element represents the completion progress of a task.
<details open>
<summary>Show/Hide me</summary>
<p class="xsmall">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim, mollitia.</p>
</details>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim, mollitia.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim, mollitia.
This is the element which enables audio in a webpage without the need of any plugins.
<audio src="path/to/music.ext" loop controls autoplay preload="metadata">
<!-- fallback here, such as Flash or some error message -->
</audio>
Browser vendors couldn't agree with what codec to support because of patents and such, therefore each one support a different set of codecs. So you set various sources:
<audio loop controls autoplay preload="auto">
<source src="path/to/music.mp3" />
<source src="path/to/music.ogg" />
<source src="path/to/music.wav" />
<!-- fallback here, such as Flash or some error message -->
</audio>
SNES ISSSD
SNES MegamanX
This is the table of codecs currently supported by each browser:
This is the element which enables video in a webpage without the need of any plugins.
<video src="path/to/video.ext" loop controls autoplay preload="metadata" style="width:100px;height:100px;" poster="path/to/imageposter.ext" >
<!-- fallback here, such as Flash or some error message -->
</video>
The same browser agreement shows up on video, the same way as audio, each one support a different set of codecs. So you set various sources:
<video loop controls autoplay preload="metadata" style="width:100px;height:100px;" poster="path/to/imageposter.ext" >
<source src="path/to/video.mp4" />
<source src="path/to/video.webm" />
<source src="path/to/video.ogv" />
<!-- fallback here, such as Flash or some error message -->
</video>
This is the table of codecs currently supported by each browser:
Will be given after the CSS3 and Responsive Design talks, as a mix of the 3 presentations!