Lesson 19: APIs
In addition to specifying markup, HTML5 also lets you use APIs.
In this lesson, you will learn what APIs are and why you might be interested in the HTML5 APIs.
What is an API?
An API is an application programming interface, which is just a fancy way of saying that it's a way to send instructions between programmes. In this case, the instructions are between your web page and the browser to, for example, show a Google Map or offer a fullscreen view of your page.
Generally speaking, APIs are a way for you to offer more interactivity into your page.
What kinds of APIs are there?
There are a lot of APIs you can use in HTML5, too many to cover in this tutorial, but we'll cover the big ones.
- Drawing: You can let people draw on your web page using the
- Audio/Video: You can now add a video right into your web page without having to embed a player or use YouTube. You can even add play/pause and other controls.
- Drag and drop: You can allow people to move things around on your page.
- Autofocus: Focusses the page on a specific item by moving the cursor there.
- Editable: You can make content editable. We mentioned this briefly in Lesson 16.
- History: You can add controls for going back or forward to specific pages or to relative pages (the page you were at before this one, for example).
The simplest API is autofocus. When the page loads, it takes your reader right to that spot. Let's try it on our forms page. Locate the country input box on your forms.htm page and add the
<input autofocus="autofocus" type="text" list="country" name="countries">
Save the file and try it out! Your cursor should be right inside the "Country" text box and the box should be highlighted.
Warning: If you autofocus to a place that is pretty far down the page, you might throw people off a bit. Test it out first.
We're going to learn some of the other APIs in the next two lessons, so keep reading!
|Related topics in the||Replies||Views|
|No related topics yet|