官术网_书友最值得收藏!

Applying the outline algorithm

Luckily for us, HTML5 now has a method of assembling an outline of our pages in browsers, so search engines as well as accessibility technologies can make better sense of them. We're going to make use of the HTML5 Outliner at: http://gsnedders.html5.org/outliner

Getting ready

To use the HTML5 Outliner, we can use HTML stored on our local computer or code visible via a URL. Make sure to save the code we've been creating locally or upload it to a publicly accessible web server for this step.

How to do it...

Let's make sure to save this document either on a local hard drive or remote server. We'll visit http://gsnedders.html5.org/outliner to create our outline.

Using our previous code example, we can generate the following code outline:

  1. Roxane is my name.
  2. Untitled Section
  3. About
  4. Work
  5. Contact
  6. What I'm Reading
  7. Elsewhere
  8. All rights reserved. Copyright Roxane.

How it works...

"It is defined in terms of a walk over the nodes of a DOM tree, in tree order, with each node being visited when it is entered and when it is exited during the walk." - WHATWG

There's more...

It's assumed that content following any heading is related to that heading. Therefore we can use many of the new HTML5 tags like <section> to explicitly demonstrate the beginning and ending of related content.

Are you sure?

If the HTML5 Outliner tool displays messages like "Untitled Section" you should rethink how you're using each of your tags and ensure your approach matches the intent of the specification.

An exception

"Untitled Section" messages should be treated as warnings instead of errors. While <section> and other new HTML5 tags require a heading tag, it's perfectly valid not to have one for <nav> areas.

Remember accessibility

The outline created ensures us that the code we've created is compliant with the W3C's standards for markup, as well as advanced technologies like WAI-ARIA for accessibility requirements.

Tip

Good accessibility design is good web design.

See also

The http://html5doctor.com site is a terrific interactive reference written by seven thought leaders including Rich Clark, Bruce Lawson, Jack Osborne, Mike Robinson, Remy Sharp, Tom Leadbetter, and Oli Studholme.

主站蜘蛛池模板: 绵竹市| 都匀市| 县级市| 泰和县| 新兴县| 金寨县| 闸北区| 彰化市| 那坡县| 武义县| 都江堰市| 建始县| 乐亭县| 梁河县| 辽阳县| 南丹县| 和政县| 巢湖市| 西乡县| 金华市| 雷山县| 基隆市| 西丰县| 田东县| 惠水县| 车险| 平陆县| 平阳县| 闵行区| 周宁县| 平潭县| 新丰县| 荔波县| 宁明县| 渑池县| 乐陵市| 西充县| 资源县| 绥德县| 丰都县| 忻城县|