Re: limiting width of div (or other container) to width of text

by "Tim Rivera" <lists(at)timrivera.com>

 Date:  Fri, 24 Jan 2003 06:22:18 -0500
 To:  <hwg-style(at)hwg.org>,
<amcbainezzell(at)alum.mit.edu>
 References:  STARRYKNIGHT
  todo: View Thread, Original
> I believe the problem is that you are expecting a block element to
> behave like an inline element. H1 and DIV are block elements, and
> extend from the left to the right of the container. If you did
> something like this:
>
> [h1][span id="headerBoxTraining"]Header 1[/span][/h1]
>
> you might get what you want, since SPAN is inline.


Yes, John hit the nail on the head with his response. You will need to use
an inline element to do what you would like to do. Try this:

#headerBoxTraining {
border: 2px solid #ccc;
border-left: 0;
padding: 10px 5px 10px 0;
}

<h1><span id="headerBoxTraining">Header 1</span></h1>



Tim

HWG hwg-style mailing list archives, maintained by Webmasters @ IWA