Sharon Go wrote:

> However, after reading this from the validator:
>
> "This might mean that you need a containing element, or possibly that
> you've forgotten to close a previous element."
>
> I just added a wrapper div around the h2:
>
> <dt>
>    <div><h2></h2></div>
> </dt>

Apparently you did not revalidate, since you would have noticed that the 
wrapper does not make the markup valid. In a sense, it is _less_ valid 
now, since the <dt> element now contains two nested block elements 
instead of one; it must not contain any block element.

> And it seems to work fine. For now.

Indeed, for now and for some values of "work" (and "fine" and "seems"). 
Since the document is invalid, all bets are off, with or without CSS.

In practice the tag sallad may "work" in the sense of acting as 
"commands" that specify some assumed default rendering and allowing you 
to tune that rendering with CSS. But what would be the point? You can, 
in principle, never know what a browser has as default rendering for a 
<dl> and its children.

So it would be simpler to start from some <div> markup with class 
attributes. Then you could safely assume that a <div> is by default a 
full-width (width: auto) block and nothing else, and start building any 
styling you like.

Even better, you could use <h2> if you really have a heading for some 
content and perhaps <ul> markup if you really have a list. You would 
then have to consider the default renderings these might have, but this 
would be much less risky, since it is reasonable to expect that any 
special defaults in a browser are consistent with the semantic ideas of 
"2nd level heading" and "(unnumbered) list".

The markup in your example is

  <dl>
   <dt><h2><a href="#">List header</a></h2></dt>
   <dd>Definition item #1</dd>
   <dd>Definition item #2</dd>
   <dd>Definition item #3</dd>
   </dd>
  </dl>

which looks somewhat weird. Are you really defining that the meanings of 
the phrase "list header" are "definition item #1" etc.?

It is common to use <dl> for all kinds of description lists, but this 
implies inflexibility in addition to being illogical. If you boss wants 
you to make some string _both_ a <dt> element content _and_ an <h2> 
element content, he is asking you to give him a square circle.

If he wants the default rendering of <h2> elements (whatever that might 
be in each browser), at least as the starting point for styling, then 
the only possible approach is to use <h2> markup. By HTML syntax, this 
limits the constructs inside which it may appear, so you either need to 
use invalid markup with all the unpredictable consequences or use other 
elements than <dl> markup as outer markup.

Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/ 

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to