Indenting with XHTML

J

Jukka K. Korpela

Andy Dingley said:
I'd avoid using <br /> in XHTML

Empty elements generally reflect flaws in the design of HTML
(as I've explained in boring detail at
http://www.cs.tut.fi/~jkorpela/html/empty.html )
but in practical authoring we need to play with the tools they gave us.
If, as I strongly suspect, the OP is using XHTML because some
XML-reading 'bot process is going to be processing these same
documents.

You are always so positive and optimistic. :) In my experience, over
99 % of people who use (in some sense) XHTML do that just because someone
told them XHTML is cool/modern/newest recommendation/sexy.
In that case, a mixed content model like <br /> (both
elements and text as siblings) is a pain to work with, using typical
XML tools.

Pardon? The content model of the br element is EMPTY. Maybe you mean that
e.g. the li element has mixed content (both text and br elements)? Well,
your suggestion still has mixed contant (text and span elements, plus
a ul element):
<li>
<span class="sub-assembly-count" >3</span> x <span
class="sub-assembly-name" >Assembly 452</span>
consisting of...
<ul>

Whether the verbose spamming... oops spanning is needed depends on what
the data will be used for. If it's programmatically generated from a
database or textfile, it is easy to add any desired span markup - but
it's also easy to add it _later_ when it will actually be needed, as
opposite to adding it now just because it might be needed some day.

Anyway, if you plain to generate the line break via CSS, you have a few
problems:
- there won't be no line break when CSS is off
- you can't do it effectively (at present) just by telling a browser
to break a line after span.sub-assembly-name
- you could do it using display: block for the "consisting of..." text,
but you haven't made _it_ an element!

Using <br /> is not a horrendous option. Using <div> might be better,
both as a little more logical move and as a way of making some stuff an
element, which can then be styled if desired:

<li>
<div>3 &times; Assembly 452</div>
<div>consisting of…</div>

Add class attributes and <span> as needed, mix well, and serve with
tag sallad.
 
J

Jennifer

John said:
Hi,

I need to produce XHTML (transitional or strict) documents, that display
invoices. A typical invoice might be:

1 x Assembled Part
consisting of ...
5 x Large Bolt
10 x Small Bolt
3 x Assembly 452
consisting of ...
1 x Mending Plate
3 x Self-Tapping Screw
3 x Bottle of Oil
5 x Toolkit A
consisting of ...
1 x Spanner
1 x Hammer
1 x Stapler

What is the best (most standards-compliant and clean coded) way to
format this list in XHTML? I am open to all suggestions (not just those
that look like the above). The indentation works well at displaying the
nesting, but there could well be other better ways. This document will
be non-geek viewable though, so nested brackets and such like are out of
the question.

Cheers,

John


You could also use style sheets to indent. Such as:

<style>
..aIndent { text-indent: 2em; }
..bIndent { text-indent: 4em; }
</style>
1 x Assembled Part<br />
consisting of ...<br />
<div class="aIndent">5 x Large Bolt</div>
<div class="aIndent">10 x Small Bolt</div>
<div class="aIndent">3 x Assembly 452</div>
<div class="aIndent">consisting of ...</div>
<div class="bIndent">1 x Mending Plate</div>
<div class="bIndent">3 x Self-Tapping Screw</div>
3 x Bottle of Oil<br />
5 x Toolkit A<br />
consisting of ...<br />
<div class="aIndent">1 x Spanner</div>
<div class="aIndent">1 x Hammer</div>
<div class="aIndent">1 x Stapler</div>

That way you can control how much you want to indent.

Jen
 
A

Andy Dingley

Pardon? The content model of the br element is EMPTY. Maybe you mean that
e.g. the li element has mixed content (both text and br elements)?

That's what I meant, but what I really should have said is more
specific than that.

The problem isn't the mixed content, it's the use of mixed content
_alone_ to represent structure.

The fragment
"3 x Assembly 452<br />consisting of..."

isn't good XML practice. Parsing this relies on using the ordering of
text fragments either side of the <br /> element. It's much better to
use the verbose version with the <span>s, or even this simplified
version (which is closer to the <br/> example, although I'd still
recommend the other)

<span class="first-bit">3 x Assembly 452</span>
<br />consisting of...


Now that I've got you on the hook, I'd suggest using <dt> & <dd>
anyway :cool:

Anyway, if you plain to generate the line break via CSS, you have a few
problems:

In that case leave the <br /> in. There's nothing wrong with using
it, it's just that it doesn't help in structuring the content for the
machine-readable case.
 
N

Neal

So you need a definition for "list" too? A definition list is a list of
definitions, apparently.

So we could not use dl markup to, say, separate a speaker's name from the
words they speak, then? ;)
 
J

Jukka K. Korpela

Neal said:
So we could not use dl markup to, say, separate a speaker's name from
the words they speak, then? ;)

Well, what prevents you from doing so, or using <blockquote> for mere
indentation (which is _not_ forbidden by the W3C - au contraire, they
declare it as deprecated, which implicitly means it's allowed)?
What prevents _me_ is simple logic and semantics. You are not defining
the speaker's name as a term.
 
S

Sam Hughes

(e-mail address removed) (Jennifer) wrote in
You could also use style sheets to indent. Such as:

<style>
.aIndent { text-indent: 2em; }
.bIndent { text-indent: 4em; }
</style>

You forgot to mention that stylesheets are supposed to be put inside the
<head> element.

You forgot to include a type="text/css" attribute in the style element.
1 x Assembled Part<br />
consisting of ...<br />
<div class="aIndent">5 x Large Bolt</div>
<div class="aIndent">10 x Small Bolt</div>
<div class="aIndent">3 x Assembly 452</div>
<div class="aIndent">consisting of ...</div>
<div class="bIndent">1 x Mending Plate</div>
<div class="bIndent">3 x Self-Tapping Screw</div>
3 x Bottle of Oil<br />
5 x Toolkit A<br />
consisting of ...<br />
<div class="aIndent">1 x Spanner</div>
<div class="aIndent">1 x Hammer</div>
<div class="aIndent">1 x Stapler</div>

That way you can control how much you want to indent.

You could also do the same thing with unordered lists, and that use would
be semantically correct.
 
N

Neal

Well, what prevents you from doing so, or using <blockquote> for mere
indentation (which is _not_ forbidden by the W3C - au contraire, they
declare it as deprecated, which implicitly means it's allowed)?

How I read it is that UAs are required to allow the non-semantic use of
blockquote. But it really doesn't require a change in how things are done.
The only explicit thing mentioned is "don't put quotes around it" but that
would hardly be correct style for an indented quote.

But I suppose the fact that it's deprecated in favor of stylesheets simply
means that old documents which use blockquote in this manner aren't
suddenly wrong.
What prevents _me_ is simple logic and semantics. You are not defining
the speaker's name as a term.

I'm not arguing that point. I agree totally in practice.

The specs do mention the elements involved as definition list, definition
term and definition description. Then they come out with this:

"Another application of DL, for example, is for marking up dialogues, with
each DT naming a speaker, and each DD containing his or her words."

.... which makes no sense if we consider what a definition is. But it's in
the specs, so it's technically allowed. Bizarre.

Note also that the Note: sections are described as informative, but the
above isn't explicitly informative or normative as far as I can see. Why
include this sentence at all unless they meant to encourage creative use
of this markup for non-definition content?

3.2 and 2.0 don't include any language in describing dl's which allude to
anything other than standard terms and descriptions - so why was this
added? I'd sure love to know that story.
 
J

Jukka K. Korpela

Neal said:
How I read it is that UAs are required to allow the non-semantic use
of blockquote.

An interesting interpretation. In what sense are they required to "allow"
it? They are not allowed to crash when they see it? :) Or do you mean
that browsers are not allowed to speak "quote" before a <blockquote>
element and "unquote" after it? Or otherwise indicate it as a block
quotation?
The only explicit thing mentioned is "don't put quotes
around it"

It's a "should not", not "shall not" or "must not". I think you know that
makes a big difference in standards parlance (W3C recommendations are not
standards, but they make big and partly serious attempts at looking like
standards).

Nevertheless, it _is_ absurd indeed, and shows where we end up when we
start mixing semantics and "I use this because both browsers show it the
way I like" authoring, making concessions to the latter.

I guess they really didn't think about Braille rendering, for example (or
much else for that matter), when they wrote that "should not". How can
you indicate quoted text as quoted in Braille without using quotation
marks of some kind? (I count words like "quote" and "unquote" as
quotation marks of a kind in this context.)
but that would hardly be correct style for an indented quote.

That's a matter of style actually, and HTML specs should take no position
But I suppose the fact that it's deprecated in favor of stylesheets
simply means that old documents which use blockquote in this manner
aren't suddenly wrong.

That's further handwaving and pointless compromise. (Compromise: a
decision that combines the drawbacks of all proposed solutions.)
They were always wrong, and the absurd babble tries to make them less
The specs do mention the elements involved as definition list,
definition term and definition description. Then they come out with
this:

"Another application of DL, for example, is for marking up dialogues,
with each DT naming a speaker, and each DD containing his or her
words."

... which makes no sense if we consider what a definition is.
Exactly.

But it's in the specs, so it's technically allowed. Bizarre.

It's a note about "application of DL", which is hardly a normative
statement that would affect the defined meaning of DL. Just as they
haven't changed the meaning of BLOCKQUOTE by the babble about indents,
though they surely make clear there were mixed ideas in the working group
about all this.

Similarly, if they said that another application of BLOCKQUOTE is
indenting text (as they effectively say, more or less), would that change
the meaning of BLOCKQUOTE? To what?
Note also that the Note: sections are described as informative, but
the above isn't explicitly informative or normative as far as I can
see.

It describes a usage, instead of saying "shall", "should", or something
else in normative terms or giving a definition. Thus, the content of the
statement makes it descriptive. Whether it's informative is moot, but
it's surely not normative.
Why include this sentence at all unless they meant to encourage
creative use of this markup for non-definition content?

Because the working group had mixed opinions and they decided not to
decide, in order to produce a "specification" fast enough. W3C
specifications are not standards.
3.2 and 2.0 don't include any language in describing dl's which
allude to anything other than standard terms and descriptions - so
why was this added? I'd sure love to know that story.

I don't know the story; I just made an educated guess. Some people in the
working group didn't care about semantics (and effectively wanted to
define BLOCKQUOTE as 'indent', DL as 'indented list with non-indented
parts indicated as DT'), some did (and wanted to keep the semantic
definitions*), and they were forced to reach a "consensus". But I think I
don't want to know the dirty details of the story.
*) I guess there was no argument over the _names_, which clearly
associate with the semantic definitions. The tag names were already part
of the HTML tradition and hard-wired into existing documents and existing
browsers.
 
N

Neal

An interesting interpretation. In what sense are they required to "allow"
it? They are not allowed to crash when they see it? :) Or do you mean
that browsers are not allowed to speak "quote" before a <blockquote>
element and "unquote" after it? Or otherwise indicate it as a block
quotation?

The latter, clearly. Which is, as we agree, dumb. Should've left the
markup abusers in the dust.
It's a "should not", not "shall not" or "must not".

Yes, I should have noted. ;)
I guess they really didn't think about Braille rendering, for example (or
much else for that matter), when they wrote that "should not". How can
you indicate quoted text as quoted in Braille without using quotation
marks of some kind? (I count words like "quote" and "unquote" as
quotation marks of a kind in this context.)

Well, hadn't considered that. Makes sense.
They were always wrong, and the absurd babble tries to make them less
wrong; to the extent they do that, they manage to make <blockquote> lose
its meaning.
Indeed.


Because the working group had mixed opinions and they decided not to
decide, in order to produce a "specification" fast enough. W3C
specifications are not standards.

A shame though. Yet they are as close as we have to standards.
... I think I
don't want to know the dirty details of the story.

Perhaps we're better off not...
 
J

John

John said:
Hi,

I need to produce XHTML (transitional or strict) documents, that display
invoices. A typical invoice might be:

1 x Assembled Part
consisting of ...
5 x Large Bolt
10 x Small Bolt
3 x Assembly 452
consisting of ...
1 x Mending Plate
3 x Self-Tapping Screw
3 x Bottle of Oil
5 x Toolkit A
consisting of ...
1 x Spanner
1 x Hammer
1 x Stapler

What is the best (most standards-compliant and clean coded) way to
format this list in XHTML? I am open to all suggestions (not just those
that look like the above). The indentation works well at displaying the
nesting, but there could well be other better ways. This document will
be non-geek viewable though, so nested brackets and such like are out of
the question.

Cheers,

John

Thanks to all for the information and detailed justification. It does
have to be machine readable (i'm not just using XHTML because I like the
w3c logo!), but i like some of the solutions I've seen for indentation.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top