[html5] Processing instruction
Jukka K. Korpela
jukka.k.korpela at kolumbus.fi
Sun Jan 8 06:06:38 PST 2012
2012-01-08 14:48, David Leunen wrote:
> As I understand it, processing instructions are not allowed in HTML5. Am
> I correct ?
As far as I can see, they are allowed in XHTML serialization, as per XML
> If so, what is the equivalent ?
> Should I use :
> - an empty <span data-foo="bar"/> for that ?
No, there's nothing to be gained and a lot to be lost by using
"self-closing" syntax for elements that are not empty by definition.
This would be better:
But if the content to be added may contain block elements and if this is
not an inline context, it would be better to use
since then you could, if desired, just insert content there, instead of
replacing the element.
Using an id attribute lets you identify the element uniquely. I don't
see a need for data- attributes here _unless_ you wish to include
invisible data (other than an identifier) to be used by the process that
> - an empty <hr> ?
No, because it gets rendered (and there is no sure way to prevent this -
you would need to rely on CSS).
> - a comment ?
Possible, but clumsy and risky.
> - a PIs anyway (because even if not allowed, they seem to be treated
> like comments anyway) ?
Perhaps not very risky in practice, but there doesn't seem to be any
reason to use PIs.
> (The semantic meaning of the metadata is more of less "this is where my
> application may insert comments")
So it's something that empty elements were designed for in SGML. But
that's water under the bridge now, and you have to live with what we've got.
More information about the Help