Re: List Markup



On 1 Oct, 14:06, shapper <mdmo...@xxxxxxxxx> wrote:
Hello,

I am displaying Articles and Documents in two different page.

An Article contains a Title, Image, Update Date and Text.
An Document contains a Title and a Updated Date. The title is the link
to the file.

Why are you doing this? Is it purely to display them, or is the
structure of this list going to be processed further mechanically? Is
there the slightest chance of that?

If you're convinced it's the first, then still code in a way to
support the second - you can't predict the future, maybe I'll want to
build a web service in the future that accesses your data and makes
use of it. So code to encourage this, not to make it difficult.

There are several small guidelines that emerge from this decision:

* Use a list element and a series of list-item elements. This makes
access to them _far_ easier, if they're explict as DOM elements,
rather than implicit by grouping. Doing it by plain sequence works for
trivial HTML, but it's ugly for semantic web data access and it's also
awkward for more soophisticated use of CSS (particularly if you wish
to float list items as individuals).

* Use <ul><li> rather than <div><div> The difference is trivial and
you can and should still apply classes to them. The difference
externally is that "HTML semantics aware" clients can recognise that
you've offered a list of elements, rather than _only_ specific clients
that understand your use of class names being able to do this.

* Avoid <dt><dd> They rely on sequence for their semantics, not
containment. That's a pain to work with.

* Avoid markup like this <h2>Article title<span>Update at 20-10-2009</
span></h2>

The problem is that that's "mixed content model" markup -
understanding the semantics of some of this text ("Article title")
requires you to identify it from being _outside_ a particular element
(or sometimes a sibling), rather than purely from the elements that
it's inside. That's a real pain to make use of, but easy to avoid.

Similarly for your main item body content - give it an individual and
distinguishable wrapper.


Use this:
<h2><span class="title" >Article title</span><span class="date"
Update at 20-10-2009</span></h2>

Or even better,
<h2><div class="title" >Article title</div><div class="date" >Update
at 20-10-2009</div></h2>
or
<h2 class="title" >Article title</h2><div class="date" >Update at
20-10-2009</div>


Use XHTML markup, not HTML
For a long time, there has been no point in publishing XHTML to the
web, as IE couldn't handle it and it was easier to support IE by
offering it HTML than by offering the Appendix C "XHTML as HTML" hack
that IE does support. This is still true: XHTML is valuable inside
CMS, but more trouble for web publishing.

However the ground rules are now changing, and it's because of the
desire to support web service clients that are looking to retrieve
your content and make intelligent use of it. These are the community
that make it worthwhile to offer XHTML content (as it's easily XML
parseable) rather than HTML.

Note though that XHTML not only should be well-formed XML, but that to
be useful it MUST be well-formed XML. The old days of careless HTML
coding should be left behind.


You should also start looking at data model and metadata approaches
from tools like RDF, RDFa and Dublin Core.


.



Relevant Pages


Loading