XHTML2 {u/a}nd XForms (original) (raw)

Steven Pemberton, W3C/CWI, Amsterdam, The Netherlands

About me

Researcher at the Dutch national research centre CWI (first European Internet site)

Co-designed the programming language ABC, that was later used as the basis for Python

In the late 80's designed and built a browser, with extensible markup, stylesheets, vector graphics, client-side scripting, etc. Ran on Mac, Unix, Atari ST

Organised 2 workshops at the first Web conference in 1994

Co-author of HTML4, CSS, XHTML, XML Events, XForms, etc

Chair of W3C HTML and Forms working groups

Until recently Editor-in-Chief of ACM/interactions.

XHTML2: The next generation in the X/HTML family

In designing XHTML2, a number of design aims were kept in mind to help direct the design. These included:

As generic XML as possible: if a facility exists in XML, try to use that rather than duplicating it. This means that it already works to a large extent in existing browsers (main missing functionality XForms and XML Events).

Less presentation, more structure: use stylesheets for defining presentation.

More usability: within the constraints of XML, try to make the language easy to write, and make the resulting documents easy to use.

More accessibility: 'designing for our future selves' – the design should be as inclusive as possible.

XHTML2 (more)

Better internationalization.

More device independence: new devices coming online, such as telephones, PDAs, tablets, televisions and so on mean that it is imperative to have a design that allows you to author once and render in different ways on different devices, rather than authoring new versions of the document for each type of device.

Better forms: after a decade of experience, we now know how to make forms a better experience.

Less scripting: achieving functionality through scripting is difficult for the author and restricts the type of user agent you can use to view the document. We have tried to identify current typical usage, and include those usages in markup.

Better semantics: integrate XHTML into the Semantic Web.

Try to please as many people at once

Keep old communities happy

Keep new communities happy

Backwards compatibility

Earlier versions of HTML claimed to be backwards compatible with previous versions.

For instance, HTML4

<meta name="author" content="Steven Pemberton">

puts the content in an attribute and not in the content of the element for this reason.

In fact, the only version of HTML that is in any sense backwards compatible is XHTML1 (others all added new functionality like forms and tables).

XHTML2 takes advantage of CSS not to be element-wise backwards compatible, but architecturally backwards compatible.

For instance, as mentioned already, much of XHTML2 works already in existing browsers.

A Simple Example

XHTML2 is recognisably a family member:

Virtual Library

Moved to example.org.

Structure and Presentation

Remove all presentation-oriented elements

Add more structuring elements

Use CSS for all presentation

Butterfly

Post

focus

gemination

party

Bodysnatchers

worm

Structure

One of the biggest problems for non-sighted people with many HTML pages is working out what the structure is. Often the only clue is the level of header used (h1, h2 etc), and often they are not used correctly.

To address this, in XHTML2 you can now make the structure of your documents more explicit, with the

and elements.

A heading ...
A lower-level heading ...

Structuring advantages

Advantages include:

h1-h6 are currently still available.


It is amazing how little issues can take so much effort.

A question that we often had to address was "is


presentational?"

The Japanese community were also asking for a .

And then we had an aha moment...

James Joyce Ulysses

James Joyce Ulysses <hr>

James Joyce Ulysses

James Joyce Ulysses <hr>

James Joyce Ulysses

James Joyce Ulysses <hr>

Separator

These are all


s!
is not presentational, but structural: a lightweight section separator.

The only thing wrong with


is that it is not (necessarily) horizontal, and not (necessarily) a rule!

We already needed a separator element for navigation lists, so we just decided to do away with all the confusion and rename


to .

Better paragraphs

A paragraph is now much closer to what people perceive as a paragraph. For instance, this is now allowed:

Advantages include:

Images

You might be surprised to know that was not in the original HTML.

is actually badly designed:

So what we have done is allowed the src attribute on any element. The image replaces the element content, and the element content is fallback. Essentially we have added fallback, moved the longdesc into the document, merged it with alt, and allowed it to be marked up all in one go.

Walk down the steps from the platform turn left, and walk on to the end of the street

Image types

HTML4 has the 'type' attribute in a number of places as a hint to the browser as to what it could expect if it went and got a resource.

But it is pretty useless. Some browsers ignore it, some don't.

Now it is a specification of the type, and meshes with the HTTP accept: field.

This means that

...

will give you a GIF, or otherwise give you the fallback.

Similarly, you can write:

...

or

...

Whitespace and pre

In HTML the only method to retain whitespace in content is with<pre>.

IN XHTML2, all elements can use the attributelayout="relevant".

...

This doesn't impose a fixed-width font on the output, just that spaces and newlines are preserved.

Lines


splits a paragraph into different parts, but they are unaddressable with CSS.

So instead of a breaking element, XHTML2 uses a structuring element:

Steven Pemberton
CWI/W3C
Amsterdam

is now

Steven Pemberton CWI/W3C Amsterdam

This gives you many more presentational possibilities, such as automatic numbering of lines, or colouring of alternate lines, etc.

Hypertext

In a non-backwards compatible step, HTML4 allowed any element to become the target of a link (with id on any element).

XHTML2 extends this by now allowing any element to become the source of a link as well, by allowing href anywhere.

So, instead of

  • W3C
  • you may now write

  • W3C
  • though is still available.

    One thing you see everywhere on the web are menus for navigation, implemented with script.

    XHTML2 now supports these natively:

    Go
  • Home
  • Technical reports
  • ...

    Whether they are presented as menus, or in some other way, depends on the platform, the stylesheet, etc.

    dir, edit

    Certain things that used to be done with elements are now done with attributes:

    and

    <span **dir="rlo"**>...

    media

    In certain places in HTML4/XHTML1 you can say that an element applies only to a specific media, like: