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 × Assembly 452</div>
<div>consisting of…</div>
Add class attributes and <span> as needed, mix well, and serve with
tag sallad.