HighDots Forums  

dt background-color control?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss dt background-color control? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ivo.welch@anderson.ucla.edu
 
Posts: n/a

Default dt background-color control? - 03-11-2005 , 01:58 PM







dear wizards:

How do I control how far to the right a background color extends in a
definition list? For example,

<dl>
<dt style="background-color:blue;">Definition</dt>
<dd>Text</dd>
</dl>

my browser draws the blue background all the way to the right. I would
like it to end with the text. (I understand that I could give it its
own html tag, but this would of course defeat the purpose.)

help appreciated. /iaw

PS: I believe <div> is the "general-purpose" paragraph element. is
there something equivalent for <i>text</i>, which I could then define
attributes for?


Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: dt background-color control? - 03-12-2005 , 12:55 PM






ivo.welch (AT) anderson (DOT) ucla.edu wrote:

Quote:
dl
dt style="background-color:blue;">Definition</dt
dd>Text</dd
/dl

my browser draws the blue background all the way to the right. I
would like it to end with the text.
The dt element is typically treated as a block element by default (as
suggested in the sample style sheet for HTML 4 in the CSS 2 spec, too).
To override this, and to make the element's box just as wide as its
content requires, you can use

dt { display: inline; }

You might wish to add some padding to make the appearance more
pleasant, e.g.

dt { padding: 0 0.2em; }

Quote:
PS: I believe <div> is the "general-purpose" paragraph element.
No, it is a block level element with no semantics (no meaning).
However some programs use the concept "paragraph" freely, so that e.g.
headings are paragraphs too; effectively, they mean "block".

Quote:
is there something equivalent for <i>text</i>, which I could then
define attributes for?
The meaningless (semantically empty) inline (text-level) element is
<span>. It's a counterpart to <div>. In CSS terms, the difference
between <span> and <div> is that <span> has display: inline by default
and <div> has display: block by default.

(Some people use <a> instead of <span>, on the grounds that <a> is
semantically empty, too, when it has neither a name attribure nor an
href attribute. But this is rare and not quite orthodox/kosher/pure.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.