Important

This slide deck was created for use in a controlled environment, during a talk. It works best with Chrome at 1280x720 or 1280x768. It may or may not work properly in other browsers. The demos were live coded, so these slides are a bit pointless if you never watched the talk.

HTML Secrets

By Lea Verou (@LeaVerou)

Picture of me
Hi, I’m Lea

#funfact

I grew up in Lesbos, Greece

…which technically makes me geogrpahically Lesbian

CSS WG Invited Expert

MIT HCI researcher @ CSAIL

CSS Secrets by O’Reilly ★★★★★ on Amazon

HTML?!

What this talk is not about

caniuse.com
github.com/search?q=details+polyfill

<a download>

PrismJS

application/octet-stream, filename

FooJS

<input type="file">

mime/*, extensions, multiple

<dialog>

open attribute, dialog.showModal(), Esc to close, dialog.close(), ::backdrop

Ceiling cat is watching

Greetings, hoomans.

Parental Advisory Inline Event Handlers

for demo purposes only!

method=dialog, returnValue, close event

Are you a cat?

<iframe>

data:, srcdoc | sandbox


if (!("srcdoc" in document.createElement("iframe"))) {
	$$("iframe[srcdoc]").forEach(iframe => {
		var srcdoc = iframe.getAttribute("srcdoc");
		iframe.src = "data:text/html," + srcdoc;
	});
}

<input type="range">

autocomplete

Need https for credit card info!

<datalist>

<details> & <summary>

no summary, details[open]

My title Content
First section Content
Other section More Content
Third section Even More Content
document.body.addEventListener("toggle", evt => {
	var accordion = evt.target.closest(".accordion");
	if (evt.target.open && accordion) {
		$$("details", accordion).forEach(details => {
			if (details != evt.target) {
				details.open = false;
			}
		});
	}
}, true);

		details::marker {
			content: "+";
		}

		details[open]::marker {
			content: "-";
		}

HTML Constraint Validation

minlength, :invalid, required

a, a+, (?=.*[A-Z]).*\d+.*, custom message, dynamic pattern

no pattern, RegExp('^' + this.getAttribute('pattern') + '$').test(this.value), with title

element.setCustomValidity("message")

maxlength

Structured data

Vocabulary: schema.org

Open Graph protocol (og), Microformats

Encoding: Microdata

RDFa, JSON-LD, Microformats

schema.org RDFa

schema.org JSON-LD


			<script type="application/ld+json">
			{
				"@context": "http://schema.org/",
				...
				"aggregateRating": {
					"@type": "AggregateRating",
					"ratingValue": "4.96",
					"reviewCount": "23"
				},
				...
			}
			</script>
		

Microformats Microformats

Open Graph RDFa

<section itemscope itemtype="http://schema.org/Recipe">
	<link itemprop="url"
	      href="http://allrecipes.com/recipe/231374/[…]and-parmesan" />
	<meta itemprop="mainEntityOfPage" content="True" />

	<img src="http://images.media-allrecipes.com/[…].jpg"
	     alt="Risotto with Truffle and Parmesan"
	     itemprop="image"/>
	<h1 itemprop="name">Risotto with Truffle and Parmesan</h1>

	<p>Prep     <time itemprop="prepTime" datetime="PT20M">20 m</time>
	<p>Cook     <time itemprop="cookTime" datetime="PT30M">30 m</time>
	<p>Ready In <time itemprop="totalTime" datetime="PT50M">50 m</time>
w3.org/TR/html51 html.spec.whatwg.org