Previous Message
Next Message

Re: [css-d] Styling DTs

Sent by Nik Schramm on 14 August 2002 00:12


On 13.Aug.02 23:02 Saila, Craig spoke thusly

> In a situation like this:
> <dl>
>   <dt>term</dt>
>   <dd>definition</dd>
> </dl>
> I want to run the DD beside DT (as opposed to below, and indented).
> Currently I'm using:
>    dt { float: left; }
> Is there a "better" way (other than "display: run-in", which I think
> would be the right rule, but has no support)?
> 

The <dl> tag actually has a (deprecated) attribute named compact which 
can do this for you automatically, provided the indentation of the <dd> 
element is set large enough to accomodate the <dt> on the same line.

[code]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>Compact Attribute</title>
	<style type="text/css">
	/*<![CDATA[*/
	/* indent set to 100px to accomodate dt tag on same line */
	dd { margin-left: 100px; padding-left: 100px; }
	/*]]>*/
	</style>
</head>
<body>
<dl compact="compact">
	<dt>Hello World</dt>
	<dd>Silly saying often said when there is nothing much to say.</dd>
</dl>
</body>
</html>

[/code]

As I said, the compact attribute is deprecated in XHTML Strict, but FWIW 
it still validates as XHTML 1 Transitional and may therefore be 
acceptable in your situation. If not, accept my apologies and back to 
pure css :)

-- 
/nik
Previous Message
Next Message

Possibly related: